Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] golang MQTT library: Question on use of RWMutex

Hi Jason,
 
The RLock on the router is supposed to prevent a subscribe/unsubscribe action from changing the state of the router while we are doing a lookup to match against an incoming message.
Looking at the code I can't understand why it's doing the locking the way it is at the moment.
 
Allan Stockdill-Mander, GCFA
Security - Project Alchemy
Phone: +44 1962 815415 (37245415 Internal)
 
 
----- Original message -----
From: Jason Swails <jswails@xxxxxxxxxx>
Sent by: paho-dev-bounces@xxxxxxxxxxx
To: "paho-dev@xxxxxxxxxxx" <paho-dev@xxxxxxxxxxx>
Cc:
Subject: [paho-dev] golang MQTT library: Question on use of RWMutex
Date: Thu, Mar 10, 2016 7:24 PM
 

Hello,

 

While using a somewhat outdated version of the Paho MQTT library for Go, we ran into the bug reported here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=439667.  Making the suggested change there (i.e., locking around the sequential call to r.defaultHandler instead of unlocking around it) fixes the test suite under Go 1.4, but I’m trying to better understand the purpose of what this r/w mutex lock is doing.  I realize that the defaultHandler in this case is only being called when a matching callback for one of the posted messages can’t be found (since there’s no matching pub topic), but I’m still confused as to why the serialized call to the callback function releases its read lock while the serialized call to defaultHandler acquires a read lock before releasing it.

 

So I have two questions here:

 

1.       What is the router lock guarding here?

2.       Should the serialized defaultHandler call (when order is true) be releasing the lock and reacquiring it after it returns like the callback does earlier in the function?  Why or why not?

 

Thanks!

Jason

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Back to the top