aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-09-27 12:32:19 -0400
committerNick Mathewson <nickm@torproject.org>2015-01-14 11:12:40 -0500
commite47a90a976f883571bea6e58620aa13f058873e3 (patch)
treede86a0e575b7b2b53b127548ca4ab990e2cc476a /src
parentd69717f61bd9ab4e0a6097f0201bd02fc96f88eb (diff)
downloadtor-e47a90a976f883571bea6e58620aa13f058873e3.tar.gz
tor-e47a90a976f883571bea6e58620aa13f058873e3.zip
"Recursive" locks, not "reentrant" locks. Duh.
Diffstat (limited to 'src')
-rw-r--r--src/common/compat_pthreads.c16
-rw-r--r--src/common/compat_threads.c6
-rw-r--r--src/common/compat_threads.h8
-rw-r--r--src/common/compat_winthreads.c2
4 files changed, 16 insertions, 16 deletions
diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c
index 59834270a3..69f7bac9c9 100644
--- a/src/common/compat_pthreads.c
+++ b/src/common/compat_pthreads.c
@@ -45,7 +45,6 @@ static pthread_attr_t attr_detached;
/** True iff we've called tor_threads_init() */
static int threads_initialized = 0;
-
/** Minimalist interface to run a void function in the background. On
* Unix calls fork, on win32 calls beginthread. Returns -1 on failure.
* func should not return, but rather should call spawn_exit.
@@ -79,9 +78,10 @@ spawn_exit(void)
}
/** A mutex attribute that we're going to use to tell pthreads that we want
- * "reentrant" mutexes (i.e., once we can re-lock if we're already holding
+ * "recursive" mutexes (i.e., once we can re-lock if we're already holding
* them.) */
-static pthread_mutexattr_t attr_reentrant;
+static pthread_mutexattr_t attr_recursive;
+
/** Initialize <b>mutex</b> so it can be locked. Every mutex must be set
* up with tor_mutex_init() or tor_mutex_new(); not both. */
void
@@ -90,7 +90,7 @@ tor_mutex_init(tor_mutex_t *mutex)
int err;
if (PREDICT_UNLIKELY(!threads_initialized))
tor_threads_init();
- err = pthread_mutex_init(&mutex->mutex, &attr_reentrant);
+ err = pthread_mutex_init(&mutex->mutex, &attr_recursive);
if (PREDICT_UNLIKELY(err)) {
log_err(LD_GENERAL, "Error %d creating a mutex.", err);
tor_fragile_assert();
@@ -98,9 +98,9 @@ tor_mutex_init(tor_mutex_t *mutex)
}
/** As tor_mutex_init, but initialize a mutex suitable that may be
- * non-reentrant, if the OS supports that. */
+ * non-recursive, if the OS supports that. */
void
-tor_mutex_init_nonreentrant(tor_mutex_t *mutex)
+tor_mutex_init_nonrecursive(tor_mutex_t *mutex)
{
int err;
if (PREDICT_UNLIKELY(!threads_initialized))
@@ -232,8 +232,8 @@ void
tor_threads_init(void)
{
if (!threads_initialized) {
- pthread_mutexattr_init(&attr_reentrant);
- pthread_mutexattr_settype(&attr_reentrant, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutexattr_init(&attr_recursive);
+ pthread_mutexattr_settype(&attr_recursive, PTHREAD_MUTEX_RECURSIVE);
tor_assert(0==pthread_attr_init(&attr_detached));
tor_assert(0==pthread_attr_setdetachstate(&attr_detached, 1));
threads_initialized = 1;
diff --git a/src/common/compat_threads.c b/src/common/compat_threads.c
index ba48eb4d1f..f018475e18 100644
--- a/src/common/compat_threads.c
+++ b/src/common/compat_threads.c
@@ -33,12 +33,12 @@ tor_mutex_new(void)
return m;
}
/** Return a newly allocated, ready-for-use mutex. This one might be
- * non-reentrant, if that's faster. */
+ * non-recursive, if that's faster. */
tor_mutex_t *
-tor_mutex_new_nonreentrant(void)
+tor_mutex_new_nonrecursive(void)
{
tor_mutex_t *m = tor_malloc_zero(sizeof(tor_mutex_t));
- tor_mutex_init_nonreentrant(m);
+ tor_mutex_init_nonrecursive(m);
return m;
}
/** Release all storage and system resources held by <b>m</b>. */
diff --git a/src/common/compat_threads.h b/src/common/compat_threads.h
index 1b59391d3b..a5db72d45f 100644
--- a/src/common/compat_threads.h
+++ b/src/common/compat_threads.h
@@ -46,9 +46,9 @@ typedef struct tor_mutex_t {
tor_mutex_t *tor_mutex_new(void);
-tor_mutex_t *tor_mutex_new_nonreentrant(void);
+tor_mutex_t *tor_mutex_new_nonrecursive(void);
void tor_mutex_init(tor_mutex_t *m);
-void tor_mutex_init_nonreentrant(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);
@@ -56,8 +56,8 @@ void tor_mutex_uninit(tor_mutex_t *m);
unsigned long tor_get_thread_id(void);
void tor_threads_init(void);
-/** Conditions need nonreentrant mutexes with pthreads. */
-#define tor_mutex_init_for_cond(m) tor_mutex_init_nonreentrant(m)
+/** Conditions need nonrecursive mutexes with pthreads. */
+#define tor_mutex_init_for_cond(m) tor_mutex_init_nonrecursive(m)
void set_main_thread(void);
int in_main_thread(void);
diff --git a/src/common/compat_winthreads.c b/src/common/compat_winthreads.c
index e19b1cae85..4820eb3481 100644
--- a/src/common/compat_winthreads.c
+++ b/src/common/compat_winthreads.c
@@ -53,7 +53,7 @@ tor_mutex_init(tor_mutex_t *m)
InitializeCriticalSection(&m->mutex);
}
void
-tor_mutex_init_nonreentrant(tor_mutex_t *m)
+tor_mutex_init_nonrecursive(tor_mutex_t *m)
{
InitializeCriticalSection(&m->mutex);
}