Commit cb186021 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

posix: add support for BSD SO_NOSIGPIPE socket option

parent bc43f3ac
...@@ -304,6 +304,9 @@ int vlc_socket (int pf, int type, int proto, bool nonblock) ...@@ -304,6 +304,9 @@ int vlc_socket (int pf, int type, int proto, bool nonblock)
fcntl (fd, F_SETFD, FD_CLOEXEC); fcntl (fd, F_SETFD, FD_CLOEXEC);
if (nonblock) if (nonblock)
fcntl (fd, F_SETFL, fcntl (fd, F_GETFL, 0) | O_NONBLOCK); fcntl (fd, F_SETFL, fcntl (fd, F_GETFL, 0) | O_NONBLOCK);
#ifdef SO_NOSIGPIPE
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &(int){ 1 }, sizeof (int));
#endif
return fd; return fd;
} }
...@@ -328,6 +331,10 @@ int vlc_accept (int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock) ...@@ -328,6 +331,10 @@ int vlc_accept (int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock)
fd = accept4 (lfd, addr, alen, flags); fd = accept4 (lfd, addr, alen, flags);
while (fd == -1 && errno == EINTR); while (fd == -1 && errno == EINTR);
# ifdef SO_NOSIGPIPE
if (fd != -1)
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &(int){ 1 }, sizeof (int));
# endif
if (fd != -1 || errno != ENOSYS) if (fd != -1 || errno != ENOSYS)
return fd; return fd;
#endif #endif
...@@ -341,6 +348,9 @@ int vlc_accept (int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock) ...@@ -341,6 +348,9 @@ int vlc_accept (int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock)
fcntl (fd, F_SETFD, FD_CLOEXEC); fcntl (fd, F_SETFD, FD_CLOEXEC);
if (nonblock) if (nonblock)
fcntl (fd, F_SETFL, fcntl (fd, F_GETFL, 0) | O_NONBLOCK); fcntl (fd, F_SETFL, fcntl (fd, F_GETFL, 0) | O_NONBLOCK);
#ifdef SO_NOSIGPIPE
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &(int){ 1 }, sizeof (int));
#endif
} }
return fd; return fd;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment