summaryrefslogtreecommitdiff
path: root/code/core/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'code/core/timer.c')
-rw-r--r--code/core/timer.c11
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