diff options
author | Uros Majstorovic <majstor@majstor.org> | 2017-08-04 16:18:31 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2017-08-04 16:18:31 +0200 |
commit | 902f62eca99bd936afd06dc4109c3918d100d9a4 (patch) | |
tree | 3c6be770370e241629a5df01a7aafba43501941e /code/core/timer.c | |
parent | f33714d52452dd19781785ca3cdf3cbd2cce6212 (diff) |
fixed threads; fixed conn_close
Diffstat (limited to 'code/core/timer.c')
-rw-r--r-- | code/core/timer.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/code/core/timer.c b/code/core/timer.c index 7767e67..8368742 100644 --- a/code/core/timer.c +++ b/code/core/timer.c @@ -3,10 +3,11 @@ #include <string.h> int ecp_timer_create(ECPTimer *timer) { + int rv = ECP_OK; timer->head = -1; #ifdef ECP_WITH_PTHREAD - int rv = pthread_mutex_init(&timer->mutex, NULL); + rv = pthread_mutex_init(&timer->mutex, NULL); if (rv) return ECP_ERR; #endif @@ -118,7 +119,6 @@ void ecp_timer_remove(ECPConnection *conn) { #ifdef ECP_WITH_PTHREAD pthread_mutex_lock(&timer->mutex); - pthread_mutex_lock(&conn->mutex); #endif for (i=timer->head; i>=0; i--) { @@ -130,13 +130,18 @@ void ecp_timer_remove(ECPConnection *conn) { } else { memset(timer->item+i, 0, sizeof(ECPTimerItem)); } +#ifdef ECP_WITH_PTHREAD + pthread_mutex_lock(&conn->mutex); +#endif conn->refcount--; +#ifdef ECP_WITH_PTHREAD + pthread_mutex_unlock(&conn->mutex); +#endif timer->head--; } } #ifdef ECP_WITH_PTHREAD - pthread_mutex_unlock(&conn->mutex); pthread_mutex_unlock(&timer->mutex); #endif |