mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-14 21:59:45 +00:00

frr_with_mutex(...) { ... } locks and automatically unlocks the listed mutex(es) when the block is exited. This adds a bit of safety against forgetting the unlock in error paths & co. and makes the code a slight bit more readable. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
24 lines
252 B
Plaintext
24 lines
252 B
Plaintext
@@
|
|
expression E;
|
|
iterator name frr_with_mutex;
|
|
@@
|
|
|
|
- pthread_mutex_lock(E);
|
|
+ frr_with_mutex(E) {
|
|
- {
|
|
...
|
|
- }
|
|
- pthread_mutex_unlock(E);
|
|
+ }
|
|
|
|
|
|
@@
|
|
expression E;
|
|
@@
|
|
|
|
- pthread_mutex_lock(E);
|
|
+ frr_with_mutex(E) {
|
|
...
|
|
- pthread_mutex_unlock(E);
|
|
+ }
|