Browse Source

v8: posix: handle EINTR in socket functions

The socket functions did not handle EINTR (syscall interrupted by signal) which
tripped up the debug agent.
v0.9.1-release
Ben Noordhuis 13 years ago
parent
commit
ebfb8a5613
  1. 23
      deps/v8/src/platform-posix.cc

23
deps/v8/src/platform-posix.cc

@ -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 {
@ -446,7 +450,10 @@ bool POSIXSocket::Connect(const char* host, const char* port) {
}
// Connect.
do
status = connect(socket_, result->ai_addr, result->ai_addrlen);
while (status == -1 && errno == EINTR);
freeaddrinfo(result);
return status == 0;
}
@ -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;
}

Loading…
Cancel
Save