[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r9862: Check return values from pthread_mutex functions. (in tor/trunk: . src/common)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r9862: Check return values from pthread_mutex functions. (in tor/trunk: . src/common)
- From: nickm@xxxxxxxx
- Date: Sat, 17 Mar 2007 17:09:53 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sat, 17 Mar 2007 17:10:06 -0400
- Reply-to: or-talk@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: nickm
Date: 2007-03-17 17:09:49 -0400 (Sat, 17 Mar 2007)
New Revision: 9862
Modified:
tor/trunk/
tor/trunk/ChangeLog
tor/trunk/src/common/compat.c
Log:
r12191@catbus: nickm | 2007-03-15 15:33:37 -0400
Check return values from pthread_mutex functions.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r12191] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2007-03-17 16:18:36 UTC (rev 9861)
+++ tor/trunk/ChangeLog 2007-03-17 21:09:49 UTC (rev 9862)
@@ -38,8 +38,9 @@
try to use \ consistently on windows and / consistently on unix: it
makes the log messages nicer.
- o Minor bugfixes:
+ o Minor bugfixes (other):
- Stop allowing hibernating servers to be "stable" or "fast".
+ - Check return values from pthread_mutex functions.
o Minor bugfixes (controller), reported by daejees:
- Make 'getinfo fingerprint' return a 551 error if we're not a
Modified: tor/trunk/src/common/compat.c
===================================================================
--- tor/trunk/src/common/compat.c 2007-03-17 16:18:36 UTC (rev 9861)
+++ tor/trunk/src/common/compat.c 2007-03-17 21:09:49 UTC (rev 9862)
@@ -1248,30 +1248,50 @@
tor_mutex_t *
tor_mutex_new(void)
{
+ int err;
tor_mutex_t *mutex = tor_malloc_zero(sizeof(tor_mutex_t));
- pthread_mutex_init(&mutex->mutex, NULL);
+ err = pthread_mutex_init(&mutex->mutex, NULL);
+ if (PREDICT_UNLIKELY(err)) {
+ log_err(LD_GENERAL, "Error %d creating a mutex.", err);
+ tor_fragile_assert();
+ }
return mutex;
}
/** Wait until <b>m</b> is free, then acquire it. */
void
tor_mutex_acquire(tor_mutex_t *m)
{
+ int err;
tor_assert(m);
- pthread_mutex_lock(&m->mutex);
+ err = pthread_mutex_lock(&m->mutex);
+ if (PREDICT_UNLIKELY(err)) {
+ log_err(LD_GENERAL, "Error %d locking a mutex.", err);
+ tor_fragile_assert();
+ }
}
/** Release the lock <b>m</b> so another thread can have it. */
void
tor_mutex_release(tor_mutex_t *m)
{
+ int err;
tor_assert(m);
- pthread_mutex_unlock(&m->mutex);
+ err = pthread_mutex_unlock(&m->mutex);
+ if (PREDICT_UNLIKELY(err)) {
+ log_err(LD_GENERAL, "Error %d unlocking a mutex.", err);
+ tor_fragile_assert();
+ }
}
/** Free all storage held by the lock <b>m</b>. */
void
tor_mutex_free(tor_mutex_t *m)
{
+ int err;
tor_assert(m);
- pthread_mutex_destroy(&m->mutex);
+ err = pthread_mutex_destroy(&m->mutex);
+ if (PREDICT_UNLIKELY(err)) {
+ log_err(LD_GENERAL, "Error %d destroying a mutex.", err);
+ tor_fragile_assert();
+ }
tor_free(m);
}
/** Return an integer representing this thread. */