From 37062d4ab6d7029403e6e3cf3af6b902e2fb2995 Mon Sep 17 00:00:00 2001 From: ehouse Date: Fri, 8 Apr 2005 14:17:28 +0000 Subject: [PATCH] mutex replaced by rwlock --- relay/ctrl.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/relay/ctrl.cpp b/relay/ctrl.cpp index da25ac3e5..553281e0f 100644 --- a/relay/ctrl.cpp +++ b/relay/ctrl.cpp @@ -43,7 +43,7 @@ #include "xwrelay_priv.h" /* this is *only* for testing. Don't abuse!!!! */ -extern pthread_mutex_t gCookieMapMutex; +extern pthread_rwlock_t gCookieMapRWLock; typedef int (*CmdPtr)( int socket, const char** args ); @@ -112,9 +112,9 @@ static int cmd_lock( int socket, const char** args ) { if ( 0 == strcmp( "on", args[1] ) ) { - pthread_mutex_lock( &gCookieMapMutex ); + pthread_rwlock_wrlock( &gCookieMapRWLock ); } else if ( 0 == strcmp( "off", args[1] ) ) { - pthread_mutex_unlock( &gCookieMapMutex ); + pthread_rwlock_unlock( &gCookieMapRWLock ); } else { print_sock( socket, "%s [on|off] (lock/unlock mutex)", args[0] ); } @@ -191,6 +191,7 @@ ctrl_thread_main( void* arg ) } } close ( socket ); + return NULL; } void @@ -206,4 +207,7 @@ run_ctrl_thread( int ctrl_listener ) pthread_t thread; int result = pthread_create( &thread, NULL, ctrl_thread_main, (void*)newSock ); + if ( result ) { + logf( "pthread_create(ctrl) => %d", result ); + } }