summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c396513)
raw | patch | inline | side by side (parent: c396513)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 5 Dec 2013 17:26:16 +0000 (18:26 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 5 Dec 2013 17:26:16 +0000 (18:26 +0100) |
… and block if necessary. There is no reason that a client should handle
partial responses.
partial responses.
src/client/sock.c | patch | blob | history |
diff --git a/src/client/sock.c b/src/client/sock.c
index f4f4c556e82012c99927c721fe98697933c939d0..b3be6157996fe7002661b783db2c055d7a382e45 100644 (file)
--- a/src/client/sock.c
+++ b/src/client/sock.c
while (42) {
ssize_t status;
+ /* XXX: use select */
+
errno = 0;
status = sdb_strbuf_read(buf, client->fd, req);
if (status < 0) {
if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
- break;
+ continue;
return status;
}
else if (! status) /* EOF */
break;
}
+ if (total != req) {
+ /* unexpected EOF; clear partially read data */
+ sdb_strbuf_skip(buf, data_offset, sdb_strbuf_len(buf));
+ return 0;
+ }
+
if (rstatus != UINT32_MAX)
/* remove status,len */
sdb_strbuf_skip(buf, data_offset, 2 * sizeof(rstatus));