Tor  0.4.7.0-alpha-dev
Functions
compat_mutex.c File Reference

Portable wrapper for platform mutex implementations. More...

#include "lib/lock/compat_mutex.h"
#include "lib/malloc/malloc.h"

Go to the source code of this file.

Functions

tor_mutex_ttor_mutex_new (void)
 
tor_mutex_ttor_mutex_new_nonrecursive (void)
 
void tor_mutex_free_ (tor_mutex_t *m)
 

Detailed Description

Portable wrapper for platform mutex implementations.

Definition in file compat_mutex.c.

Function Documentation

◆ tor_mutex_free_()

void tor_mutex_free_ ( tor_mutex_t m)

Release all storage and system resources held by m.

Destroying a locked mutex is undefined behaviour. Global mutexes may be locked when they are passed to this function, because multiple threads can still access them. So we can either:

  • destroy on shutdown, and re-initialise when tor re-initialises, or
  • skip destroying and re-initialisation, using a sentinel variable. See #31735 for details.

Definition at line 42 of file compat_mutex.c.

◆ tor_mutex_new()

tor_mutex_t* tor_mutex_new ( void  )

Return a newly allocated, ready-for-use mutex.

Definition at line 17 of file compat_mutex.c.

Referenced by tor_gmtime_r_msg(), and tor_localtime_r_msg().

◆ tor_mutex_new_nonrecursive()

tor_mutex_t* tor_mutex_new_nonrecursive ( void  )

Return a newly allocated, ready-for-use mutex. This one might be non-recursive, if that's faster.

Definition at line 26 of file compat_mutex.c.