zos: fix setsockopt error when using AF_UNIX
PR-URL: https://github.com/libuv/libuv/pull/2224 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Yury Selivanov <yury@magic.io> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
3c521dedb4
commit
fd67cd538c
@ -268,16 +268,30 @@ static void uv__udp_sendmsg(uv_udp_t* handle) {
|
|||||||
* are different from the BSDs: it _shares_ the port rather than steal it
|
* are different from the BSDs: it _shares_ the port rather than steal it
|
||||||
* from the current listener. While useful, it's not something we can emulate
|
* from the current listener. While useful, it's not something we can emulate
|
||||||
* on other platforms so we don't enable it.
|
* on other platforms so we don't enable it.
|
||||||
|
*
|
||||||
|
* zOS does not support getsockname with SO_REUSEPORT option when using
|
||||||
|
* AF_UNIX.
|
||||||
*/
|
*/
|
||||||
static int uv__set_reuse(int fd) {
|
static int uv__set_reuse(int fd) {
|
||||||
int yes;
|
int yes;
|
||||||
|
|
||||||
#if defined(SO_REUSEPORT) && !defined(__linux__)
|
|
||||||
yes = 1;
|
yes = 1;
|
||||||
|
|
||||||
|
#if defined(SO_REUSEPORT) && defined(__MVS__)
|
||||||
|
struct sockaddr_in sockfd;
|
||||||
|
unsigned int sockfd_len = sizeof(sockfd);
|
||||||
|
if (getsockname(fd, (struct sockaddr*) &sockfd, &sockfd_len) == -1)
|
||||||
|
return UV__ERR(errno);
|
||||||
|
if (sockfd.sin_family == AF_UNIX) {
|
||||||
|
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)))
|
||||||
|
return UV__ERR(errno);
|
||||||
|
} else {
|
||||||
|
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)))
|
||||||
|
return UV__ERR(errno);
|
||||||
|
}
|
||||||
|
#elif defined(SO_REUSEPORT) && !defined(__linux__)
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)))
|
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)))
|
||||||
return UV__ERR(errno);
|
return UV__ERR(errno);
|
||||||
#else
|
#else
|
||||||
yes = 1;
|
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)))
|
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)))
|
||||||
return UV__ERR(errno);
|
return UV__ERR(errno);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user