base: Make heim_log_ref() thread-safe
This is necessary to making multiple `krb5_context`s be able to share a log facility.
This commit is contained in:
@@ -52,7 +52,7 @@ struct heim_log_facility_internal {
|
||||
|
||||
struct heim_log_facility_s {
|
||||
char *program;
|
||||
size_t refs;
|
||||
volatile heim_base_atomic(size_t) refs;
|
||||
size_t len;
|
||||
struct heim_log_facility_internal *val;
|
||||
};
|
||||
@@ -156,7 +156,7 @@ heim_log_facility *
|
||||
heim_log_ref(heim_log_facility *fac)
|
||||
{
|
||||
if (fac)
|
||||
fac->refs++;
|
||||
heim_base_atomic_inc(&fac->refs);
|
||||
return fac;
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ heim_closelog(heim_context context, heim_log_facility *fac)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!fac || --(fac->refs))
|
||||
if (!fac || heim_base_atomic_dec(&fac->refs))
|
||||
return;
|
||||
for (i = 0; i < fac->len; i++)
|
||||
(*fac->val[i].close_func)(fac->val[i].data);
|
||||
|
Reference in New Issue
Block a user