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 ;-)
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;
}
}
lastpoint += len;
SEND;
+ DEBUG("OK!\n");
continue;
}
/* READ */