diff options
author | jsorg71 <jsorg71> | 2009-01-15 07:59:47 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2009-01-15 07:59:47 +0000 |
commit | b5c0a076578e11fb5fccf43c5efce90aa7c04d6f (patch) | |
tree | 5318b5df0ad2fb74a526e0c471b9f50318833374 /sesman | |
parent | a71ca6bc1fcea4b4b6ccf0a51d94eb4b79cd764f (diff) | |
download | xrdp-proprietary-b5c0a076578e11fb5fccf43c5efce90aa7c04d6f.tar.gz xrdp-proprietary-b5c0a076578e11fb5fccf43c5efce90aa7c04d6f.zip |
use the thread_calls in common the mutexes and semaphores
Diffstat (limited to 'sesman')
-rw-r--r-- | sesman/lock.c | 69 | ||||
-rw-r--r-- | sesman/lock.h | 32 | ||||
-rw-r--r-- | sesman/sesman.h | 1 |
3 files changed, 44 insertions, 58 deletions
diff --git a/sesman/lock.c b/sesman/lock.c index 4c404fdc..eb1abe81 100644 --- a/sesman/lock.c +++ b/sesman/lock.c @@ -23,74 +23,67 @@ #include "sesman.h" -#include <semaphore.h> -#include <pthread.h> - extern struct config_sesman* g_cfg; -pthread_mutex_t lock_chain; /* session chain lock */ -pthread_mutexattr_t lock_chain_attr; /* mutex attributes */ - -pthread_mutex_t lock_config; /* configuration access lock */ -pthread_mutexattr_t lock_config_attr; /* mutex attributes */ - -static tbus g_sync_mutex; -static tbus g_sync_sem; +static tbus g_sync_mutex = 0; +static tbus g_lock_chain = 0; +static tbus g_sync_sem = 0; +static tbus g_lock_socket = 0; -sem_t lock_socket; - -void DEFAULT_CC +/******************************************************************************/ +void APP_CC lock_init(void) { - /* initializing socket lock */ - sem_init(&lock_socket, 0, 1); - - /* initializing chain lock */ - pthread_mutexattr_init(&lock_chain_attr); - pthread_mutex_init(&lock_chain, &lock_chain_attr); - - /* initializing config lock */ - pthread_mutexattr_init(&lock_config_attr); - pthread_mutex_init(&lock_config, &lock_config_attr); - g_sync_mutex = tc_mutex_create(); + g_lock_chain = tc_mutex_create(); g_sync_sem = tc_sem_create(0); + g_lock_socket = tc_sem_create(1); } /******************************************************************************/ -void DEFAULT_CC +void APP_CC +lock_deinit(void) +{ + tc_mutex_delete(g_sync_mutex); + tc_mutex_delete(g_lock_chain); + tc_sem_delete(g_sync_sem); + tc_sem_delete(g_lock_socket); +} + +/******************************************************************************/ +void APP_CC lock_chain_acquire(void) { - /*lock the chain*/ + /* lock the chain */ LOG_DBG(&(g_cfg->log), "lock_chain_acquire()"); - pthread_mutex_lock(&lock_chain); + tc_mutex_lock(g_lock_chain); } /******************************************************************************/ -void DEFAULT_CC +void APP_CC lock_chain_release(void) { - /*unlock the chain*/ + /* unlock the chain */ LOG_DBG(&(g_cfg->log), "lock_chain_release()"); - pthread_mutex_unlock(&lock_chain); + tc_mutex_unlock(g_lock_chain); } /******************************************************************************/ -void DEFAULT_CC +void APP_CC lock_socket_acquire(void) { /* lock socket variable */ LOG_DBG(&(g_cfg->log), "lock_socket_acquire()"); - sem_wait(&lock_socket); + tc_sem_dec(g_lock_socket); } /******************************************************************************/ -void DEFAULT_CC +void APP_CC lock_socket_release(void) { /* unlock socket variable */ LOG_DBG(&(g_cfg->log), "lock_socket_release()"); - sem_post(&lock_socket); + tc_sem_inc(g_lock_socket); } /******************************************************************************/ @@ -107,7 +100,7 @@ void APP_CC lock_sync_release(void) { /* unlock socket variable */ - LOG_DBG(&(g_cfg->log), "lock_socket_release()"); + LOG_DBG(&(g_cfg->log), "lock_sync_release()"); tc_mutex_unlock(g_sync_mutex); } @@ -116,7 +109,7 @@ void APP_CC lock_sync_sem_acquire(void) { /* dec sem */ - LOG_DBG(&(g_cfg->log), "lock_sync_dec()"); + LOG_DBG(&(g_cfg->log), "lock_sync_sem_acquire()"); tc_sem_dec(g_sync_sem); } @@ -125,6 +118,6 @@ void APP_CC lock_sync_sem_release(void) { /* inc sem */ - LOG_DBG(&(g_cfg->log), "lock_sync_inc()"); + LOG_DBG(&(g_cfg->log), "lock_sync_sem_release()"); tc_sem_inc(g_sync_sem); } diff --git a/sesman/lock.h b/sesman/lock.h index 5ea5e7f4..d320ff83 100644 --- a/sesman/lock.h +++ b/sesman/lock.h @@ -27,47 +27,39 @@ * @brief initializes all the locks * */ -void DEFAULT_CC +void APP_CC lock_init(void); /** * - * @brief acquires the lock for the session chain + * @brief cleanup all the locks * */ -void DEFAULT_CC -lock_chain_acquire(void); - -/** - * - * @brief releases the sessiona chain lock - * - */ -void DEFAULT_CC -lock_chain_release(void); +void APP_CC +lock_deinit(void); /** * - * @brief acquires config lock + * @brief acquires the lock for the session chain * */ -void DEFAULT_CC -lock_cfg_acquire(void); +void APP_CC +lock_chain_acquire(void); /** * - * @brief releases config lock + * @brief releases the session chain lock * */ -void DEFAULT_CC -lock_cfg_release(void); +void APP_CC +lock_chain_release(void); /** * * @brief request the socket lock * */ -void DEFAULT_CC +void APP_CC lock_socket_acquire(void); /** @@ -75,7 +67,7 @@ lock_socket_acquire(void); * @brief releases the socket lock * */ -void DEFAULT_CC +void APP_CC lock_socket_release(void); /** diff --git a/sesman/sesman.h b/sesman/sesman.h index 33c0ad2d..c62a2bbe 100644 --- a/sesman/sesman.h +++ b/sesman/sesman.h @@ -47,6 +47,7 @@ #include "scp.h" #include "thread.h" #include "lock.h" +#include "thread_calls.h" #include "libscp.h" |