Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » C Paho Api Threading Issue(paho c api thread.)
C Paho Api Threading Issue [message #1794677] Tue, 04 September 2018 19:14 Go to next message
Tom Orsi is currently offline Tom OrsiFriend
Messages: 1
Registered: September 2018
Junior Member
I have the following code using the non-async libraries/api and calling setupCallbacks(). I know you might recommend using the async library/api but we can't do that right now. So according to the documentation of

I have tried to serialize access to all paho api. When I do that I seem to get a deadlock. Seems like something doesn't release my lock but ALL of my locks are in auto-guards so they release when they go out of scope.

I suspect that the publish is trying to join on a thread that is driving the delivery callback , and I don't have time now research in the source code. Worth noting, if move the lock after the publish but still lock on the shared resource A everything works but could get a race in my resource A, this is for now mitigate-able in our code.

void TokenDeliveryCallback(...)
// access or modify shared resource A

void useThreadFunction(...)
// move lock to here an its fine.
// access or modify shared resource A
Re: C Paho Api Threading Issue [message #1795289 is a reply to message #1794677] Thu, 20 September 2018 04:08 Go to previous message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 76
Registered: March 2013
One thing to be aware of is that the only callback in the MQTTClient library that allows other MQTTClient API calls to be made within it is the connectionLost() callback - to allow a reconnect attempt to be made within it.

The other callbacks are made on the same thread, so if you make another MQTTClient API call within one, it will deadlock. Maybe this is what you are seeing.
Previous Topic:MQTT-SN Gateway: sleeping client not working
Next Topic:Public multiples topic to Mosquitto server using Paho C library
Goto Forum:

Current Time: Mon Oct 26 07:43:31 GMT 2020

Powered by FUDForum. Page generated in 0.01898 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top