Tor
0.4.7.0-alpha-dev
|
Header for compat_mutex.c. More...
Go to the source code of this file.
Data Structures | |
struct | tor_mutex_t |
Macros | |
#define | tor_mutex_free(m) FREE_AND_NULL(tor_mutex_t, tor_mutex_free_, (m)) |
Functions | |
tor_mutex_t * | tor_mutex_new (void) |
tor_mutex_t * | tor_mutex_new_nonrecursive (void) |
void | tor_mutex_init (tor_mutex_t *m) |
void | tor_mutex_init_nonrecursive (tor_mutex_t *m) |
void | tor_mutex_acquire (tor_mutex_t *m) |
void | tor_mutex_release (tor_mutex_t *m) |
void | tor_mutex_free_ (tor_mutex_t *m) |
void | tor_mutex_uninit (tor_mutex_t *m) |
void | tor_locking_init (void) |
Header for compat_mutex.c.
Definition in file compat_mutex.h.
#define tor_mutex_free | ( | m | ) | FREE_AND_NULL(tor_mutex_t, tor_mutex_free_, (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:
Additionally, set the pointer m to NULL.
Definition at line 73 of file compat_mutex.h.
void tor_locking_init | ( | void | ) |
Initialize the locking module, if it is not already initialized.
Definition at line 29 of file compat_mutex_pthreads.c.
Referenced by tor_mutex_init_nonrecursive(), and tor_threads_init().
void tor_mutex_acquire | ( | tor_mutex_t * | m | ) |
Wait until m is free, then acquire it.
Definition at line 71 of file compat_mutex_pthreads.c.
Referenced by atomic_counter_add(), atomic_counter_exchange(), atomic_counter_get(), dup_onion_keys(), expire_old_onion_keys(), openssl_locking_cb_(), queue_reply(), threadpool_queue_update(), worker_thread_main(), and workqueue_entry_cancel().
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:
Definition at line 42 of file compat_mutex.c.
void tor_mutex_init | ( | tor_mutex_t * | mutex | ) |
Initialize mutex so it can be locked. Every mutex must be set up with tor_mutex_init() or tor_mutex_new(); not both.
Definition at line 41 of file compat_mutex_pthreads.c.
Referenced by init_logging().
void tor_mutex_init_nonrecursive | ( | tor_mutex_t * | mutex | ) |
As tor_mutex_init, but initialize a mutex suitable that may be non-recursive, if the OS supports that.
Definition at line 56 of file compat_mutex_pthreads.c.
Referenced by atomic_counter_init().
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_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.
void tor_mutex_release | ( | tor_mutex_t * | m | ) |
Release the lock m so another thread can have it.
Definition at line 84 of file compat_mutex_pthreads.c.
Referenced by atomic_counter_add(), atomic_counter_exchange(), atomic_counter_get(), dup_onion_keys(), openssl_locking_cb_(), queue_reply(), socket_accounting_unlock(), worker_thread_main(), and workqueue_entry_cancel().
void tor_mutex_uninit | ( | tor_mutex_t * | m | ) |
Clean up the mutex m so that it no longer uses any system resources. Does not free m. This function must only be called on mutexes from tor_mutex_init().
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:
Definition at line 107 of file compat_mutex_pthreads.c.
Referenced by atomic_counter_destroy(), and tor_mutex_free_().