Commit 6ed922d
committed
Fix call home client thread cleanup
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.)1 parent 821f1e0 commit 6ed922d
4 files changed
Lines changed: 27 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
268 | 269 | | |
269 | 270 | | |
270 | 271 | | |
| 272 | + | |
271 | 273 | | |
272 | 274 | | |
273 | 275 | | |
274 | 276 | | |
275 | 277 | | |
276 | | - | |
277 | | - | |
278 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | | - | |
| 518 | + | |
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
552 | | - | |
553 | | - | |
554 | 552 | | |
555 | 553 | | |
556 | 554 | | |
| |||
703 | 701 | | |
704 | 702 | | |
705 | 703 | | |
706 | | - | |
707 | | - | |
708 | | - | |
| 704 | + | |
709 | 705 | | |
710 | 706 | | |
711 | 707 | | |
| |||
2015 | 2011 | | |
2016 | 2012 | | |
2017 | 2013 | | |
2018 | | - | |
2019 | | - | |
2020 | | - | |
2021 | | - | |
2022 | | - | |
| 2014 | + | |
2023 | 2015 | | |
2024 | 2016 | | |
2025 | 2017 | | |
| |||
2081 | 2073 | | |
2082 | 2074 | | |
2083 | 2075 | | |
| 2076 | + | |
2084 | 2077 | | |
2085 | 2078 | | |
2086 | 2079 | | |
| |||
2758 | 2751 | | |
2759 | 2752 | | |
2760 | 2753 | | |
2761 | | - | |
2762 | | - | |
2763 | | - | |
2764 | | - | |
2765 | | - | |
| 2754 | + | |
2766 | 2755 | | |
2767 | 2756 | | |
2768 | 2757 | | |
| |||
2909 | 2898 | | |
2910 | 2899 | | |
2911 | 2900 | | |
| 2901 | + | |
2912 | 2902 | | |
2913 | 2903 | | |
2914 | 2904 | | |
2915 | 2905 | | |
2916 | 2906 | | |
2917 | 2907 | | |
| 2908 | + | |
2918 | 2909 | | |
2919 | 2910 | | |
2920 | 2911 | | |
| |||
2938 | 2929 | | |
2939 | 2930 | | |
2940 | 2931 | | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
2941 | 2936 | | |
2942 | 2937 | | |
2943 | 2938 | | |
| |||
2953 | 2948 | | |
2954 | 2949 | | |
2955 | 2950 | | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
2956 | 2955 | | |
2957 | 2956 | | |
2958 | 2957 | | |
| |||
2983 | 2982 | | |
2984 | 2983 | | |
2985 | 2984 | | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
2986 | 2989 | | |
2987 | 2990 | | |
2988 | 2991 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1555 | 1555 | | |
1556 | 1556 | | |
1557 | 1557 | | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
| 1558 | + | |
1561 | 1559 | | |
1562 | 1560 | | |
1563 | 1561 | | |
| |||
1628 | 1626 | | |
1629 | 1627 | | |
1630 | 1628 | | |
1631 | | - | |
1632 | | - | |
1633 | | - | |
| 1629 | + | |
1634 | 1630 | | |
1635 | 1631 | | |
1636 | 1632 | | |
| |||
0 commit comments