File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 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,
8282 return (bool ) CAS (& (bus -> clients [id ]), & null_client , & new_client );
8383}
8484
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.
8887 */
8988static bool execute_client_callback (bus_client_t * client , void * msg )
9089{
@@ -101,6 +100,9 @@ static bool execute_client_callback(bus_client_t *client, void *msg)
101100 /* If CAS succeeds, the client had the expected reference count, and
102101 * we updated it successfully. If CAS fails, the client was updated
103102 * 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.
104106 */
105107 if (CAS (client , & local_client , & new_client )) {
106108 /* Send a message and decrease the reference count back */
You can’t perform that action at this time.
0 commit comments