mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
v8: posix: handle EINTR in socket functions
The socket functions did not handle EINTR (syscall interrupted by signal) which tripped up the debug agent.
This commit is contained in:
1 parent
4359e8154d
commit
ebfb8a5613
1 file changed
+21
-4
Vendored
+21
-4
@@ -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.
|
||||
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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user