Files
buildroot/package/mosquitto/0003-Fix-mosquitto_loop_start-leaving-the-mosq-struct-in-.patch
Yann E. MORIN 583a02e398 package/mosquitto: bump to version 2.1.2
Version 2.1.x has introduced a cmake-based build, and upstream strongly
recomends using it over the legacy Makefiles, which will ultimately be
retired.

So we do the switch, which cause quite some noise in the .mk file, but
at the same time allows for a bit of cleanup in the build process, as we
can now use the cmake-package infra.

Mosquitto now wants to peek into the malloc() internals for memory
tracking, and that only works on systems with an MMU (uClibc-ng does not
expose it for noMMU builds, as it's part of its malloc-standard
implementation).

Static-only builds are broken, even when only building the library. This
seems beyond a simple repair, so just require shared libs now (since
we're requiring an MMU as well, requiring shared libs is not too much of
an additional burden).

cJSON is now a required dependency, used in common parts of the code
(not just for the plugins).

There are a few options that we forcibly disable; they'll get addressed
in followup patches.

There are still a few build failures that are difficult to account for
(except):

    $ printf 'BR2_PACKAGE_MOSQUITTO=y\n' >mosq.cfg
    $ ./utils/docker-run ./utils/test-pkg -d $(pwd)/run-tests -c mosq.cfg -p mosquitto
    br-arm-full-static [5/6]: FAILED
    => old uClibc-ng, would need __GNU_SOURCE (with dunder) to define
       getrandom(); no longer needed since uClibc-ng 1.0.50; would need
       openssl otherwise

    bootlin-aarch64-glibc-old [6/6]: FAILED
    => really old glibc, missing getrandom(); would need openssl

Drop our existing patches, they've either been applied upstream, or are
no longer needed. Add new patches to fix various build issues
(submission upstream pending the signature of the CLA..,).

Thanks a lot to Titouan for providing his initial work on the update!
Some of his findings ended up in this patch. 👍

Note: by lack of a trusted path back to the PGP key that signed the
archive, the comment was dropped, as checking a signature without a
trust-chain does not make much sense...

Co-developped-by: Titouan Christophe <titouan.christophe@mind.be>
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Cc: Peter Korsgaard <peter@korsgaard.com>
Cc: Titouan Christophe <titouan.christophe@mind.be>
[Romain: remove "mosquitto broker" comment for static builds]
Signed-off-by: Romain Naour <romain.naour@smile.fr>
2026-03-13 21:05:12 +01:00

60 lines
1.8 KiB
Diff

From cf74866a6d707d7bd2d76831f60af789e4f3ce77 Mon Sep 17 00:00:00 2001
From: "Roger A. Light" <roger@atchoo.org>
Date: Fri, 13 Feb 2026 08:33:32 +0000
Subject: [PATCH] Fix mosquitto_loop_start() leaving the mosq struct in an
invalid state
This occurs if thread creation fails.
Closes #3496. Thanks to ehoffman2.
Upstream: https://github.com/eclipse-mosquitto/mosquitto/commit/da7d02690b4c998ec4b842ae066fa642f59eb509
[yann.morin@orange.com: drop the Changelog.txt entry]
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
---
ChangeLog.txt | 4 ++--
lib/thread_mosq.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 7d6a92cf..a76fc6e1 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,11 +1,11 @@
2.1.2 - 2026-02-09
==================
-Broker:
+# Broker
- Forbid running with `persistence true` and with a persistence plugin at the
same time.
-Build:
+# Build
- Build fixes for OpenBSD. Closes #3474.
- Add missing libedit to docker builds. Closes #3476.
- Fix static/shared linking of libwebsockets under cmake.
diff --git a/lib/thread_mosq.c b/lib/thread_mosq.c
index 931bf9eb..62ddadb7 100644
--- a/lib/thread_mosq.c
+++ b/lib/thread_mosq.c
@@ -48,7 +48,6 @@ int mosquitto_loop_start(struct mosquitto *mosq)
return MOSQ_ERR_INVAL;
}
- mosq->threaded = mosq_ts_self;
if(!COMPAT_pthread_create(&mosq->thread_id, NULL, mosquitto__thread_main, mosq)){
#if defined(__linux__)
pthread_setname_np(mosq->thread_id, "mosquitto loop");
@@ -57,6 +56,7 @@ int mosquitto_loop_start(struct mosquitto *mosq)
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
pthread_set_name_np(mosq->thread_id, "mosquitto loop");
#endif
+ mosq->threaded = mosq_ts_self;
return MOSQ_ERR_SUCCESS;
}else{
return MOSQ_ERR_ERRNO;
--
2.34.1