Skip to content

Fix call home client thread cleanup#82

Merged
michalvasko merged 1 commit intoCESNET:develfrom
ADTRAN:call-home-client-id
Sep 13, 2018
Merged

Fix call home client thread cleanup#82
michalvasko merged 1 commit intoCESNET:develfrom
ADTRAN:call-home-client-id

Conversation

@alangefe
Copy link
Copy Markdown
Contributor

This commit by @thelsper fixes a race condition in call home client creation and deletion. If a call home client is deleted and then immediately re-created with the same client name, the old client thread will not notice that the old client was destroyed, and will attempt to service the new client, while the newly created client thread for the new client also attempts to service the new client! This results in a proliferation of threads and can also result in deadlock.

To fix this, we added a unique client ID to the client information. When a client thread retrieves its client by name, it will now also check the client ID against the cached value of the client ID for the client it was previously servicing. If the client ID changes, this means that the client was destroyed, and the thread will clean itself up.

While we were here making these changes we also changed the session ID to be a true atomic, and removed the spin lock that was protecting it. (stdatomic.h was added in C11, which was why we also appended -std=gnu11 to the CFLAGS. Both sysrepo and netopeer2 are already using C11.)

This commit by @thelsper fixes a race condition in call home client creation
and deletion. If a call home client is deleted and then immediately re-created
with the same client name, the old client thread will not notice that the
old client was destroyed, and will attempt to service the new client,
while the newly created client thread for the new client also attempts to
service the new client! This results in a proliferation of threads and can also
result in deadlock.

To fix this, we added a unique client ID to the client information. When
a client thread retrieves its client by name, it will now also check the client
ID against the cached value of the client ID for the client it was previously
servicing. If the client ID changes, this means that the client was destroyed,
and the thread will clean itself up.

While we were here making these changes we also changed the session ID to be
a true atomic, and removed the spin lock that was protecting it. (The atomic
operations library stdatomic.h was added in C11, which was why we also
appended `-std=gnu11` to the `CFLAGS`. Both sysrepo and netopeer2 are already
using C11.)
@michalvasko
Copy link
Copy Markdown
Member

Hi,
both changes are fine, thanks, merging.

Regards,
Michal

@michalvasko michalvasko merged commit 4243f48 into CESNET:devel Sep 13, 2018
@alangefe alangefe deleted the call-home-client-id branch September 13, 2018 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants