Skip to content

Commit

Permalink
mutexes near returns (CID #1551697, #1551698)
Browse files Browse the repository at this point in the history
1551697 Guard reference to is_exiting if HAVE_PTHREADS defined
1551698 Annotate leaving exfiles opened for exclusive use locked
  • Loading branch information
jejones3141 authored and arr2036 committed Jan 25, 2024
1 parent 9c14799 commit ac5d426
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/server/exfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ static int exfile_open_lock(exfile_t *ef, char const *filename, mode_t permissio

exfile_trigger_exec(ef, &ef->entries[i], "reserve");

/* coverity[missing_unlock] */
return ef->entries[i].fd;
}

Expand Down
10 changes: 10 additions & 0 deletions src/lib/util/atexit.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,17 @@ int fr_atexit_trigger(bool uctx_scope, fr_atexit_t func, void const *uctx)
*/
bool fr_atexit_is_exiting(void)
{
#ifdef HAVE_PTHREADS
bool save_is_exiting;

pthread_mutex_lock(&fr_atexit_global_mutex);
save_is_exiting = is_exiting;
pthread_mutex_unlock(&fr_atexit_global_mutex);

return save_is_exiting;
#else
return is_exiting;
#endif
}

#ifdef HAVE_PTHREADS
Expand Down

0 comments on commit ac5d426

Please sign in to comment.