From: yoe Date: Thu, 14 Nov 2002 22:20:54 +0000 (+0000) Subject: r26: Modified write() to be send(). X-Git-Url: http://git.alex.org.uk r26: Modified write() to be send(). 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 ;-) --- diff --git a/nbd-server.c b/nbd-server.c index 046ff05..26f5499 100644 --- a/nbd-server.c +++ b/nbd-server.c @@ -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 */