stream: retry write on EPROTOTYPE on OSX
At least on OS X 10.10 "Yosemite", an EPROTOTYPE can occur when trying to write to a socket that is shutting down. By retrying the write after EPROTOTYPE, we correctly get EPIPE. PR-URL: https://github.com/libuv/libuv/pull/482 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
96fc77d5d9
commit
406961385d
@ -809,7 +809,17 @@ start:
|
||||
do {
|
||||
n = sendmsg(uv__stream_fd(stream), &msg, 0);
|
||||
}
|
||||
#if defined(__APPLE__)
|
||||
/*
|
||||
* Due to a possible kernel bug at least in OS X 10.10 "Yosemite",
|
||||
* EPROTOTYPE can be returned while trying to write to a socket that is
|
||||
* shutting down. If we retry the write, we should get the expected EPIPE
|
||||
* instead.
|
||||
*/
|
||||
while (n == -1 && (errno == EINTR || errno == EPROTOTYPE));
|
||||
#else
|
||||
while (n == -1 && errno == EINTR);
|
||||
#endif
|
||||
} else {
|
||||
do {
|
||||
if (iovcnt == 1) {
|
||||
@ -818,7 +828,17 @@ start:
|
||||
n = writev(uv__stream_fd(stream), iov, iovcnt);
|
||||
}
|
||||
}
|
||||
#if defined(__APPLE__)
|
||||
/*
|
||||
* Due to a possible kernel bug at least in OS X 10.10 "Yosemite",
|
||||
* EPROTOTYPE can be returned while trying to write to a socket that is
|
||||
* shutting down. If we retry the write, we should get the expected EPIPE
|
||||
* instead.
|
||||
*/
|
||||
while (n == -1 && (errno == EINTR || errno == EPROTOTYPE));
|
||||
#else
|
||||
while (n == -1 && errno == EINTR);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (n < 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user