r26: Modified write() to be send().
authoryoe <yoe>
Thu, 14 Nov 2002 22:20:54 +0000 (22:20 +0000)
committeryoe <yoe>
Thu, 14 Nov 2002 22:20:54 +0000 (22:20 +0000)
Rationale: when #define'ing _LARGEFILE_SOURCE, and _FILE_OFFSET_BITS
to 64 so as to get Large File Support, some file-related syscalls are
modified to their 64 bit counterparts; write() is one of them. And
there's no such thing as a 'large' socket, which has caused nbd-server
to hang in the write() call. Changing the write() to a send() fixed
this (and I hate ugly bugs. This one took me, like, three days ;-)

nbd-server.c

index 046ff05..26f5499 100644 (file)
@@ -135,8 +135,8 @@ inline void writeit(int f, void *buf, int len)
        int res;
        while (len > 0) {
                DEBUG("+");
-               if ((res = write(f, buf, len)) <= 0)
-                       err("Write failed: %m");
+               if ((res = send(f, buf, len, 0)) <= 0)
+                       err("Send failed: %m");
                len -= res;
                buf += res;
        }
@@ -474,6 +474,7 @@ int mainloop(int net)
                        }
                        lastpoint += len;
                        SEND;
+                       DEBUG("OK!\n");
                        continue;
                }
                /* READ */