diff options
Diffstat (limited to 'libglusterfs/src/timer.c')
| -rw-r--r-- | libglusterfs/src/timer.c | 15 | 
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 (®->lock, NULL);                  reg->active.next = ®->active;                  reg->active.prev = ®->active; @@ -220,6 +221,8 @@ gf_timer_registry_init (glusterfs_ctx_t *ctx)                  reg->stale.prev = ®->stale;                  pthread_create (®->th, NULL, gf_timer_proc, ctx); +                ctx->timer = reg;          } +out:          return ctx->timer;  }  | 
