[MERGED] libosmo-netif[master]: Set SO_NOSIGPIPE on SCTP connections, for patforms which sup...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Nov 8 06:58:43 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: Set SO_NOSIGPIPE on SCTP connections, for patforms which support it (macOS, FreeBSD etc...)
......................................................................


Set SO_NOSIGPIPE on SCTP connections, for patforms which support it (macOS, FreeBSD etc...)

Change-Id: If4f2a99b2baf143551a7122f40ed1f9088c5936c
Signed-off-by: Arran Cudbard-Bell <a.cudbardb at freeradius.org>
---
M src/stream.c
1 file changed, 17 insertions(+), 1 deletion(-)

Approvals:
  Neels Hofmeyr: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/stream.c b/src/stream.c
index fd02b74..7d40df2 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -26,6 +26,14 @@
 #include <netinet/sctp.h>
 #endif
 
+/*
+ * Platforms that don't have MSG_NOSIGNAL (which disables SIGPIPE)
+ * usually have SO_NOSIGPIPE (set via setsockopt).
+ */
+#ifndef MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0
+#endif
+
 static int sctp_sock_activate_events(int fd)
 {
 #ifdef HAVE_LIBSCTP
@@ -167,8 +175,16 @@
 		ofd->when &= ~BSC_FD_WRITE;
 		LOGP(DLINP, LOGL_DEBUG, "connection done.\n");
 		cli->state = STREAM_CLI_STATE_CONNECTED;
-		if (cli->proto == IPPROTO_SCTP)
+		if (cli->proto == IPPROTO_SCTP) {
+#ifdef SO_NOSIGPIPE
+			int val = 1;
+
+			ret = setsockopt(ofd->fd, SOL_SOCKET, SO_NOSIGPIPE, (void*)&val, sizeof(val));
+			if (ret < 0)
+				LOGP(DLINP, LOGL_DEBUG, "Failed setting SO_NOSIGPIPE: %s\n", strerror(errno));
+#endif
 			sctp_sock_activate_events(ofd->fd);
+		}
 		if (cli->connect_cb)
 			cli->connect_cb(cli);
 		break;

-- 
To view, visit https://gerrit.osmocom.org/1194
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If4f2a99b2baf143551a7122f40ed1f9088c5936c
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Arran Cudbard-bell <a.cudbardb at freeradius.org>
Gerrit-Reviewer: Arran Cudbard-bell <a.cudbardb at freeradius.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list