You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2015/11/04 16:35:44 UTC

qpid-dispatch git commit: NO-JIRA - Add assertions for error codes in locks and conditions. Nullify the pn_connection context on free.

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 3eee868e6 -> f2978b897


NO-JIRA - Add assertions for error codes in locks and conditions.
          Nullify the pn_connection context on free.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/f2978b89
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/f2978b89
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/f2978b89

Branch: refs/heads/master
Commit: f2978b8972c0ee5c4c3e2289258ae5a0bf61d60c
Parents: 3eee868
Author: Ted Ross <tr...@redhat.com>
Authored: Wed Nov 4 10:34:27 2015 -0500
Committer: Ted Ross <tr...@redhat.com>
Committed: Wed Nov 4 10:34:27 2015 -0500

----------------------------------------------------------------------
 src/posix/threading.c | 32 ++++++++++++++++++++++++--------
 src/server.c          |  4 +++-
 2 files changed, 27 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/f2978b89/src/posix/threading.c
----------------------------------------------------------------------
diff --git a/src/posix/threading.c b/src/posix/threading.c
index e92b879..d641510 100644
--- a/src/posix/threading.c
+++ b/src/posix/threading.c
@@ -17,10 +17,17 @@
  * under the License.
  */
 
+//
+// Enable debug for asserts in this module regardless of what the project-wide
+// setting is.
+//
+#undef NDEBUG
+
 #include <qpid/dispatch/threading.h>
 #include <qpid/dispatch/ctools.h>
 #include <stdio.h>
 #include <pthread.h>
+#include <assert.h>
 
 struct sys_mutex_t {
     pthread_mutex_t mutex;
@@ -30,6 +37,7 @@ struct sys_mutex_t {
 #endif
 };
 
+
 // NOTE: normally it is incorrect for an assert expression to have side effects,
 // since it could change the behavior between a debug and a release build.  In
 // this case however the mutex->acquired field only exists in a debug build, so
@@ -59,7 +67,8 @@ void sys_mutex_free(sys_mutex_t *mutex)
 
 void sys_mutex_lock(sys_mutex_t *mutex)
 {
-    pthread_mutex_lock(&(mutex->mutex));
+    int result = pthread_mutex_lock(&(mutex->mutex));
+    assert(result == 0);
     ACQUIRE(mutex);
 }
 
@@ -67,7 +76,8 @@ void sys_mutex_lock(sys_mutex_t *mutex)
 void sys_mutex_unlock(sys_mutex_t *mutex)
 {
     RELEASE(mutex);
-    pthread_mutex_unlock(&(mutex->mutex));
+    int result = pthread_mutex_unlock(&(mutex->mutex));
+    assert(result == 0);
 }
 
 
@@ -94,20 +104,23 @@ void sys_cond_free(sys_cond_t *cond)
 void sys_cond_wait(sys_cond_t *cond, sys_mutex_t *held_mutex)
 {
     RELEASE(held_mutex);
-    pthread_cond_wait(&(cond->cond), &(held_mutex->mutex));
+    int result = pthread_cond_wait(&(cond->cond), &(held_mutex->mutex));
+    assert(result == 0);
     ACQUIRE(held_mutex);
 }
 
 
 void sys_cond_signal(sys_cond_t *cond)
 {
-    pthread_cond_signal(&(cond->cond));
+    int result = pthread_cond_signal(&(cond->cond));
+    assert(result == 0);
 }
 
 
 void sys_cond_signal_all(sys_cond_t *cond)
 {
-    pthread_cond_broadcast(&(cond->cond));
+    int result = pthread_cond_broadcast(&(cond->cond));
+    assert(result == 0);
 }
 
 
@@ -133,19 +146,22 @@ void sys_rwlock_free(sys_rwlock_t *lock)
 
 void sys_rwlock_wrlock(sys_rwlock_t *lock)
 {
-    pthread_rwlock_wrlock(&(lock->lock));
+    int result = pthread_rwlock_wrlock(&(lock->lock));
+    assert(result == 0);
 }
 
 
 void sys_rwlock_rdlock(sys_rwlock_t *lock)
 {
-    pthread_rwlock_rdlock(&(lock->lock));
+    int result = pthread_rwlock_rdlock(&(lock->lock));
+    assert(result == 0);
 }
 
 
 void sys_rwlock_unlock(sys_rwlock_t *lock)
 {
-    pthread_rwlock_unlock(&(lock->lock));
+    int result = pthread_rwlock_unlock(&(lock->lock));
+    assert(result == 0);
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/f2978b89/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index bca3eb2..f2f0c13 100644
--- a/src/server.c
+++ b/src/server.c
@@ -714,8 +714,10 @@ static void *thread_run(void *arg)
                 DEQ_REMOVE(qd_server->connections, ctx);
 
                 qdpn_connector_free(cxtr);
-                if (conn)
+                if (conn) {
+                    pn_connection_set_context(conn, 0);
                     pn_connection_free(conn);
+                }
                 if (ctx->collector)
                     pn_collector_free(ctx->collector);
                 invoke_deferred_calls(ctx, true);  // Discard any pending deferred calls


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org