pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/34072 )
Change subject: stream_srv: call setsockopt(SO_NOGIPIPE) also in srv sockets ......................................................................
stream_srv: call setsockopt(SO_NOGIPIPE) also in srv sockets
Change-Id: I867d8e244e473679abb7e7e7a9b531eeed046436 --- M src/stream_cli.c M src/stream_srv.c 2 files changed, 26 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/72/34072/1
diff --git a/src/stream_cli.c b/src/stream_cli.c index 72a86c3..9845f14 100644 --- a/src/stream_cli.c +++ b/src/stream_cli.c @@ -308,7 +308,7 @@ int val = 1; ret = setsockopt(osmo_stream_cli_fd(cli), SOL_SOCKET, SO_NOSIGPIPE, (void *)&val, sizeof(val)); if (ret < 0) - LOGSCLI(cli, LOGL_DEBUG, "Failed setting SO_NOSIGPIPE: %s\n", strerror(errno)); + LOGSCLI(cli, LOGL_ERROR, "Failed setting SO_NOSIGPIPE: %s\n", strerror(errno)); return ret; #else return 0; diff --git a/src/stream_srv.c b/src/stream_srv.c index 1ef2cc4..6898ef4 100644 --- a/src/stream_srv.c +++ b/src/stream_srv.c @@ -97,6 +97,20 @@ int flags; };
+static int _setsockopt_nosigpipe(struct osmo_stream_srv_link *link, int new_fd) +{ +#ifdef SO_NOSIGPIPE + int ret; + int val = 1; + ret = setsockopt(new_fd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&val, sizeof(val)); + if (ret < 0) + LOGSLNK(link, LOGL_ERROR, "Failed setting SO_NOSIGPIPE: %s\n", strerror(errno)); + return ret; +#else + return 0; +#endif +} + static int osmo_stream_srv_link_ofd_cb(struct osmo_fd *ofd, unsigned int what) { int ret; @@ -117,6 +131,7 @@ case AF_UNIX: LOGSLNK(link, LOGL_DEBUG, "accept()ed new link on fd %d\n", sock_fd); + _setsockopt_nosigpipe(link, sock_fd); break; case AF_INET6: case AF_INET: @@ -124,6 +139,7 @@ osmo_sockaddr_to_str(&osa));
if (link->proto == IPPROTO_SCTP) { + _setsockopt_nosigpipe(link, sock_fd); ret = stream_sctp_sock_activate_events(sock_fd); if (ret < 0) goto error_close_socket;