Skip to main content

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

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


Back to the top