Skip to content

Commit 41be11a

Browse files
committed
Revise the comments
1 parent 9385612 commit 41be11a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mbus/mbus.c

+5-3
Original file line numberDiff line numberDiff 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
*/
8988
static 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 */

0 commit comments

Comments
 (0)