Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
v8: posix: try to send() whole buffer
Browse files Browse the repository at this point in the history
Retry the send() syscall after a partial write.
  • Loading branch information
bnoordhuis committed Apr 24, 2012
1 parent ebfb8a5 commit 48cdbff
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions deps/v8/src/platform-posix.cc
Expand Up @@ -472,13 +472,22 @@ bool POSIXSocket::Shutdown() {


int POSIXSocket::Send(const char* data, int len) const {
int status;

do
status = send(socket_, data, len, 0);
while (status == -1 && errno == EINTR);
int written;

for (written = 0; written < len; /* empty */) {
int status = send(socket_, data + written, len - written, 0);
if (status == 0) {
break;
} else if (status > 0) {
written += status;
} else if (errno == EINTR) {
/* interrupted by signal, retry */
} else {
return -1;
}
}

return status;
return written;
}


Expand Down

0 comments on commit 48cdbff

Please sign in to comment.