From a83466b9b284858cfa8e5b1d011a01f151a6ec55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Mon, 8 Aug 2022 07:03:11 +0200 Subject: [PATCH] main/mosquitto: backport upstream patch for SIGPIPE issue See https://github.com/eclipse/mosquitto/issues/2564 (cherry picked from commit 9292d10009b450f9c432d1e43c6fa23ce2fcd528) --- ...E-to-ignore-use-MSG_NOSIGNAL-instead.patch | 67 +++++++++++++++++++ main/mosquitto/APKBUILD | 4 +- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 main/mosquitto/0001-Don-t-set-SIGPIPE-to-ignore-use-MSG_NOSIGNAL-instead.patch diff --git a/main/mosquitto/0001-Don-t-set-SIGPIPE-to-ignore-use-MSG_NOSIGNAL-instead.patch b/main/mosquitto/0001-Don-t-set-SIGPIPE-to-ignore-use-MSG_NOSIGNAL-instead.patch new file mode 100644 index 000000000000..f6b9718465fe --- /dev/null +++ b/main/mosquitto/0001-Don-t-set-SIGPIPE-to-ignore-use-MSG_NOSIGNAL-instead.patch @@ -0,0 +1,67 @@ +From 0c9d9f21633c5dbb482893a9d6bdf40111829925 Mon Sep 17 00:00:00 2001 +From: "Roger A. Light" +Date: Sun, 7 Aug 2022 23:04:46 +0100 +Subject: [PATCH] Don't set SIGPIPE to ignore, use MSG_NOSIGNAL instead. + +Closes #2564. Thanks to nmeum. +--- + lib/mosquitto.c | 4 ---- + lib/net_mosq.c | 6 +----- + lib/net_mosq.h | 5 +++++ + 4 files changed, 7 insertions(+), 9 deletions(-) + +diff --git a/lib/mosquitto.c b/lib/mosquitto.c +index 0d68d313..72762ed6 100644 +--- a/lib/mosquitto.c ++++ b/lib/mosquitto.c +@@ -109,10 +109,6 @@ struct mosquitto *mosquitto_new(const char *id, bool clean_start, void *userdata + return NULL; + } + +-#ifndef WIN32 +- signal(SIGPIPE, SIG_IGN); +-#endif +- + mosq = (struct mosquitto *)mosquitto__calloc(1, sizeof(struct mosquitto)); + if(mosq){ + mosq->sock = INVALID_SOCKET; +diff --git a/lib/net_mosq.c b/lib/net_mosq.c +index 22f5a313..d4eb89ef 100644 +--- a/lib/net_mosq.c ++++ b/lib/net_mosq.c +@@ -1041,11 +1041,7 @@ ssize_t net__write(struct mosquitto *mosq, const void *buf, size_t count) + /* Call normal write/send */ + #endif + +-#ifndef WIN32 +- return write(mosq->sock, buf, count); +-#else +- return send(mosq->sock, buf, count, 0); +-#endif ++ return send(mosq->sock, buf, count, MSG_NOSIGNAL); + + #ifdef WITH_TLS + } +diff --git a/lib/net_mosq.h b/lib/net_mosq.h +index 37a21461..ded98760 100644 +--- a/lib/net_mosq.h ++++ b/lib/net_mosq.h +@@ -19,6 +19,7 @@ Contributors: + #define NET_MOSQ_H + + #ifndef WIN32 ++# include + # include + #else + # include +@@ -51,6 +52,10 @@ typedef SSIZE_T ssize_t; + #define INVALID_SOCKET -1 + #endif + ++#ifndef MSG_NOSIGNAL ++# define MSG_NOSIGNAL 0 ++#endif ++ + /* Macros for accessing the MSB and LSB of a uint16_t */ + #define MOSQ_MSB(A) (uint8_t)((A & 0xFF00) >> 8) + #define MOSQ_LSB(A) (uint8_t)(A & 0x00FF) diff --git a/main/mosquitto/APKBUILD b/main/mosquitto/APKBUILD index e076bcecc29e..22f886348495 100644 --- a/main/mosquitto/APKBUILD +++ b/main/mosquitto/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Natanael Copa pkgname=mosquitto pkgver=2.0.14 -pkgrel=1 +pkgrel=2 pkgdesc="open source MQTT broker" url="https://mosquitto.org/" arch="all" @@ -15,6 +15,7 @@ checkdepends="python3 cunit-dev" subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-libs++:_pp $pkgname-openrc $pkgname-libs $pkgname-clients" source="http://mosquitto.org/files/source/mosquitto-$pkgver.tar.gz + 0001-Don-t-set-SIGPIPE-to-ignore-use-MSG_NOSIGNAL-instead.patch mosquitto.initd mosquitto.confd " @@ -106,6 +107,7 @@ clients() { sha512sums=" a9e4f41b9af679b30318570e86a465546024651373df10e3b132f4593b89d22d0dbac01bb7371a57132ba030a2e73971c612acb5c9ac12f5ccd06aa38d9444c2 mosquitto-2.0.14.tar.gz +d2ec296919ca9c3e31063b6b87c06c723f46347e5af4e92eaac8fe5c5d5e36faa90c8c3aa8911b3af2a470829bb032812dee57764581e1ac4da4e570b521639a 0001-Don-t-set-SIGPIPE-to-ignore-use-MSG_NOSIGNAL-instead.patch a527813957b6f2d7afdb7269bade61d99b3023a147861b38902971929ff342a7c8c276bdb808fcfe7e48fa3e5c7521a16d777e5a3313256b8bf1e759cec5b7b0 mosquitto.initd 678a8aaefb9181f5f4998304046e5a8737049f90cf6bbbfd5fd4549592728afe77cb536547b39ad1598d53fe0b7c03e1506b2683e7b936712b9fad4a317f4b43 mosquitto.confd "