Hi
Paho team,
Thank you for a great MQTT library! I’m
using the
org.eclipse.paho.mqtt.c library.
In a project connecting existing devices
to the Internet, I want a service (on the Internet) to
be able to receive messages from devices, but the
device must also be able to publish messages to the
service. This means that the device needs to run both
a publisher and a subscriber instance.
I’ve tried with the async API, running
the two instances in two separate threads (eCos). It
first seem very well, connecting success and
subscribing and I’m able both send and receive message
through a mosquito broker. But sadly I’ve found that
the API isn’t thread safe. The socket.c module holds a
list of sockets (think is called
s), but this list is static and not
protected so the list may be updated from one
instance/thread while one other is accessing it.- A
race condition causing the a zero pointer to be
accessed.
Am I abusing the library by threading two
instances in simultaneously or am I just doing it
wrong? I guess I could transfer to the sync API, but I
thought that the async API will perform better
yield-wise.
Thanks in advance.
//Daniel
______________________________________________________________________________
Daniel Rasmussen,
Software developer, Prevas A/S
Hedeager 1, 8200 Aarhus N, Denmark
Mobile: +45 40 29 24 87
Switchboard: +45 33 15 90 90
daniel.rasmussen@xxxxxxxxx
www.prevas.dk

