#include "log.h"
#include "privs.h"
#include "memory.h"
+#include "frr_pthread.h"
#include "lib_errors.h"
#include "lib/queue.h"
* Serialize 'raise' operations; particularly important for
* OSes where privs are process-wide.
*/
- pthread_mutex_lock(&(privs->mutex));
- {
+ frr_with_mutex(&(privs->mutex)) {
/* Locate ref-counting object to use */
refs = get_privs_refs(privs);
refs->raised_in_funcname = funcname;
}
}
- pthread_mutex_unlock(&(privs->mutex));
return privs;
}
/* Serialize 'lower privs' operation - particularly important
* when OS privs are process-wide.
*/
- pthread_mutex_lock(&(*privs)->mutex);
- {
+ frr_with_mutex(&(*privs)->mutex) {
refs = get_privs_refs(*privs);
if (--(refs->refcount) == 0) {
refs->raised_in_funcname = NULL;
}
}
- pthread_mutex_unlock(&(*privs)->mutex);
*privs = NULL;
}