Skip to content

Commit 99e4535

Browse files
committed
Make the mutex protecting the MQTT structure recursive.
1 parent b5c91f2 commit 99e4535

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

include/mqtt.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ int __cheri_compartment("MQTT") mqtt_unsubscribe(Timeout *t,
257257
* Fetch ACK and PUBLISH notifications on a given MQTT connection, and keep
258258
* the connection alive.
259259
*
260+
* This function will invoke the callbacks passed to `mqtt_connect`. The
261+
* connection object is protected by a recursive mutex, so these callbacks can
262+
* call additional publish and subscribe functions. If doing so, care must be
263+
* taken to ensure that the buffer is not exhausted. Calling `mqtt_run` from a
264+
* callback is not supported.
265+
*
260266
* The return value is zero if notifications were successfully fetched, or a
261267
* negative error code.
262268
*

lib/mqtt/mqtt.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace
6868
NetworkContext_t networkContext;
6969

7070
// Lock on which the whole public API synchronizes.
71-
FlagLockPriorityInherited lock;
71+
RecursiveMutex lock;
7272

7373
/**
7474
* Constructor of the CHERIoT MQTT context object. We keep

0 commit comments

Comments
 (0)