File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -82,9 +82,8 @@ bus_register(bus_t *bus,
82
82
return (bool ) CAS (& (bus -> clients [id ]), & null_client , & new_client );
83
83
}
84
84
85
- /*
86
- * Attempt to call a client's callback function to send a message.
87
- * Might fail if such client gets unregistered while attempting to send message.
85
+ /* Attempt to call a client's callback function in a loop until it succeeds or
86
+ * it gets unregistered.
88
87
*/
89
88
static bool execute_client_callback (bus_client_t * client , void * msg )
90
89
{
@@ -101,6 +100,9 @@ static bool execute_client_callback(bus_client_t *client, void *msg)
101
100
/* If CAS succeeds, the client had the expected reference count, and
102
101
* we updated it successfully. If CAS fails, the client was updated
103
102
* recently. The actual value is copied to local_client.
103
+ * We must to update the client this way instead of using
104
+ * __atomic_fetch_sub directly because we need to make sure that is
105
+ * still registered by the time we update the reference count.
104
106
*/
105
107
if (CAS (client , & local_client , & new_client )) {
106
108
/* Send a message and decrease the reference count back */
You can’t perform that action at this time.
0 commit comments