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

Commit

Permalink
v8: posix: handle EINTR in socket functions
Browse files Browse the repository at this point in the history
The socket functions did not handle EINTR (syscall interrupted by signal) which
tripped up the debug agent.
  • Loading branch information
bnoordhuis committed Apr 24, 2012
1 parent 4359e81 commit ebfb8a5
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions deps/v8/src/platform-posix.cc
Expand Up @@ -419,7 +419,11 @@ Socket* POSIXSocket::Accept() const {
return NULL;
}

int socket = accept(socket_, NULL, NULL);
int socket;
do
socket = accept(socket_, NULL, NULL);
while (socket == -1 && errno == EINTR);

if (socket == -1) {
return NULL;
} else {
Expand All @@ -446,7 +450,10 @@ bool POSIXSocket::Connect(const char* host, const char* port) {
}

// Connect.
status = connect(socket_, result->ai_addr, result->ai_addrlen);
do
status = connect(socket_, result->ai_addr, result->ai_addrlen);
while (status == -1 && errno == EINTR);

freeaddrinfo(result);
return status == 0;
}
Expand All @@ -465,13 +472,23 @@ bool POSIXSocket::Shutdown() {


int POSIXSocket::Send(const char* data, int len) const {
int status = send(socket_, data, len, 0);
int status;

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

return status;
}


int POSIXSocket::Receive(char* data, int len) const {
int status = recv(socket_, data, len, 0);
int status;

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

return status;
}

Expand Down

0 comments on commit ebfb8a5

Please sign in to comment.