diff options
Diffstat (limited to 'glusterfsd/src/glusterfsd.c')
| -rw-r--r-- | glusterfsd/src/glusterfsd.c | 60 | 
1 files changed, 47 insertions, 13 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index ebd12bf0b99..c6285b2efe1 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -1025,6 +1025,7 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)          cmd_args_t    *cmd_args = NULL;          struct rlimit  lim = {0, };          call_pool_t   *pool = NULL; +        int            ret = -1;          xlator_mem_acct_init (THIS, gfd_mt_end); @@ -1032,7 +1033,7 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)          if (!ctx->process_uuid) {                  gf_log ("", GF_LOG_CRITICAL,                          "ERROR: glusterfs uuid generation failed"); -                return -1; +                goto out;          }          ctx->page_size  = 128 * GF_UNIT_KB; @@ -1041,14 +1042,14 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)          if (!ctx->iobuf_pool) {                  gf_log ("", GF_LOG_CRITICAL,                          "ERROR: glusterfs iobuf pool creation failed"); -                return -1; +                goto out;          }          ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE);          if (!ctx->event_pool) {                  gf_log ("", GF_LOG_CRITICAL,                          "ERROR: glusterfs event pool creation failed"); -                return -1; +                goto out;          }          pool = GF_CALLOC (1, sizeof (call_pool_t), @@ -1056,7 +1057,7 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)          if (!pool) {                  gf_log ("", GF_LOG_CRITICAL,                          "ERROR: glusterfs call pool creation failed"); -                return -1; +                goto out;          }          /* frame_mem_pool size 112 * 4k */ @@ -1064,21 +1065,21 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)          if (!pool->frame_mem_pool) {                  gf_log ("", GF_LOG_CRITICAL,                          "ERROR: glusterfs frame pool creation failed"); -                return -1; +                goto out;          }          /* stack_mem_pool size 256 * 1024 */          pool->stack_mem_pool = mem_pool_new (call_stack_t, 1024);          if (!pool->stack_mem_pool) {                  gf_log ("", GF_LOG_CRITICAL,                          "ERROR: glusterfs stack pool creation failed"); -                return -1; +                goto out;          }          ctx->stub_mem_pool = mem_pool_new (call_stub_t, 1024);          if (!ctx->stub_mem_pool) {                  gf_log ("", GF_LOG_CRITICAL,                          "ERROR: glusterfs stub pool creation failed"); -                return -1; +                goto out;          }          ctx->dict_pool = mem_pool_new (dict_t, GF_MEMPOOL_COUNT_OF_DICT_T); @@ -1123,7 +1124,35 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)          lim.rlim_max = RLIM_INFINITY;          setrlimit (RLIMIT_CORE, &lim); -        return 0; +        ret = 0; +out: + +        if (ret && pool) { + +                if (pool->frame_mem_pool) +                        mem_pool_destroy (pool->frame_mem_pool); + +                if (pool->stack_mem_pool) +                        mem_pool_destroy (pool->stack_mem_pool); + +                GF_FREE (pool); +        } + +        if (ret && ctx) { +                if (ctx->stub_mem_pool) +                        mem_pool_destroy (ctx->stub_mem_pool); + +                if (ctx->dict_pool) +                        mem_pool_destroy (ctx->dict_pool); + +                if (ctx->dict_data_pool) +                        mem_pool_destroy (ctx->dict_data_pool); + +                if (ctx->dict_pair_pool) +                        mem_pool_destroy (ctx->dict_pair_pool); +        } + +        return ret;  }  static int @@ -1273,7 +1302,7 @@ int  glusterfs_pidfile_setup (glusterfs_ctx_t *ctx)  {          cmd_args_t  *cmd_args = NULL; -        int          ret = 0; +        int          ret = -1;          FILE        *pidfp = NULL;          cmd_args = &ctx->cmd_args; @@ -1286,7 +1315,7 @@ glusterfs_pidfile_setup (glusterfs_ctx_t *ctx)                  gf_log ("glusterfsd", GF_LOG_ERROR,                          "pidfile %s error (%s)",                          cmd_args->pid_file, strerror (errno)); -                return -1; +                goto out;          }          ret = lockf (fileno (pidfp), F_TLOCK, 0); @@ -1294,7 +1323,7 @@ glusterfs_pidfile_setup (glusterfs_ctx_t *ctx)                  gf_log ("glusterfsd", GF_LOG_ERROR,                          "pidfile %s lock error (%s)",                          cmd_args->pid_file, strerror (errno)); -                return ret; +                goto out;          }          gf_log ("glusterfsd", GF_LOG_TRACE, @@ -1306,12 +1335,17 @@ glusterfs_pidfile_setup (glusterfs_ctx_t *ctx)                  gf_log ("glusterfsd", GF_LOG_ERROR,                          "pidfile %s unlock error (%s)",                          cmd_args->pid_file, strerror (errno)); -                return ret; +                goto out;          }          ctx->pidfp = pidfp; -        return 0; +        ret = 0; +out: +        if (ret && pidfp) +                fclose (pidfp); + +        return ret;  }  | 
