]> andersk Git - moira.git/commitdiff
read() in a loop, not all at once, in case packets get split up
authordanw <danw>
Tue, 3 Mar 1998 23:20:03 +0000 (23:20 +0000)
committerdanw <danw>
Tue, 3 Mar 1998 23:20:03 +0000 (23:20 +0000)
update/sendrecv.c

index bc3c7458a2079b094dc6ef4cbf58765666ed4816..289007ade5b077137240e73fe8fcc2c6a5ff30c4 100644 (file)
@@ -79,6 +79,7 @@ int send_string(int conn, char *buf, size_t len)
 int recv_string(int conn, char **buf, size_t *len)
 {
   char tmp[4];
+  int size, more;
 
   if (read(conn, tmp, 4) != 4)
     {
@@ -98,7 +99,14 @@ int recv_string(int conn, char **buf, size_t *len)
       fail(conn, ENOMEM, "reading string");
       return ENOMEM;
     }
-  if (read(conn, *buf, *len) != *len)
+  for (size = 0; size < *len; size += more)
+    {
+      more = read(conn, *buf + size, *len - size);
+      if (!more)
+       break;
+    }
+  
+  if (size != *len)
     {
       free(buf);
       fail(conn, errno, "reading string");
This page took 0.042209 seconds and 5 git commands to generate.