summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/timer.c')
-rw-r--r--libglusterfs/src/timer.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c
index 7ff18f94e35..3e39231e0b7 100644
--- a/libglusterfs/src/timer.c
+++ b/libglusterfs/src/timer.c
@@ -201,18 +201,19 @@ gf_timer_proc (void *ctx)
gf_timer_registry_t *
gf_timer_registry_init (glusterfs_ctx_t *ctx)
{
- if (ctx == NULL)
- {
+ if (ctx == NULL) {
gf_log ("timer", GF_LOG_ERROR, "invalid argument");
return NULL;
}
-
+
if (!ctx->timer) {
gf_timer_registry_t *reg = NULL;
- ctx->timer = reg = GF_CALLOC (1, sizeof (*reg),
- gf_common_mt_gf_timer_registry_t);
- ERR_ABORT (reg);
+ reg = GF_CALLOC (1, sizeof (*reg),
+ gf_common_mt_gf_timer_registry_t);
+ if (!reg)
+ goto out;
+
pthread_mutex_init (&reg->lock, NULL);
reg->active.next = &reg->active;
reg->active.prev = &reg->active;
@@ -220,6 +221,8 @@ gf_timer_registry_init (glusterfs_ctx_t *ctx)
reg->stale.prev = &reg->stale;
pthread_create (&reg->th, NULL, gf_timer_proc, ctx);
+ ctx->timer = reg;
}
+out:
return ctx->timer;
}