diff options
author | Amar Tumballi <amarts@redhat.com> | 2012-03-22 04:11:38 -0700 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-03-22 04:19:35 -0700 |
commit | dc174a4d60ebca6a67e32c1834c2f0dcbff2c3c0 (patch) | |
tree | 38c67065ef92f10a7a331716ff5308e36e4546bd | |
parent | 2db6b286d091346b4386fd6091eb22bd9d3ea7a0 (diff) |
Revert "core: enable process to return the appropriate error code"
This reverts commit 16717f4df7b0fbd3c255f5faf8a2744444231bb7
Change-Id: I65624db4d31e11e1bec66b07b352ce823ef069b9
Reviewed-on: http://review.gluster.com/3001
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r-- | glusterfsd/src/glusterfsd-mgmt.c | 36 | ||||
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 43 | ||||
-rw-r--r-- | libglusterfs/src/globals.c | 3 | ||||
-rw-r--r-- | libglusterfs/src/glusterfs.h | 1 |
4 files changed, 13 insertions, 70 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index 0fe18256170..3b419262ac1 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -54,7 +54,6 @@ int glusterfs_mgmt_pmap_signin (glusterfs_ctx_t *ctx); int glusterfs_volfile_fetch (glusterfs_ctx_t *ctx); int glusterfs_process_volfp (glusterfs_ctx_t *ctx, FILE *fp); int glusterfs_graph_unknown_options (glusterfs_graph_t *graph); -int emancipate(glusterfs_ctx_t *ctx, int ret); int mgmt_cbk_spec (void *data) @@ -1537,7 +1536,7 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, if (-1 == rsp.op_ret) { gf_log (frame->this->name, GF_LOG_ERROR, "failed to get the 'volume file' from server"); - ret = rsp.op_errno; + ret = -1; goto out; } @@ -1598,8 +1597,6 @@ out: if (rsp.spec) free (rsp.spec); - emancipate (ctx, ret); - if (ret && ctx && !ctx->active) { /* Do it only for the first time */ /* Failed to get the volume file, something wrong, @@ -1643,8 +1640,6 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, cmd_args_t *cmd_args = NULL; glusterfs_ctx_t *ctx = NULL; int ret = 0; - int need_term = 0; - int emval = 0; this = mydata; ctx = this->ctx; @@ -1659,41 +1654,30 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, gf_log ("glusterfsd-mgmt", GF_LOG_INFO, "%d connect attempts left", cmd_args->max_connect_attempts); - if (0 >= cmd_args->max_connect_attempts) { - need_term = 1; - emval = ENOTCONN; - } + if (0 >= cmd_args->max_connect_attempts) + cleanup_and_exit (1); } break; case RPC_CLNT_CONNECT: rpc_clnt_set_connected (&((struct rpc_clnt*)ctx->mgmt)->conn); ret = glusterfs_volfile_fetch (ctx); - if (ret) { - emval = ret; - if (!ctx->active) { - need_term = 1; - gf_log ("glusterfsd-mgmt", GF_LOG_ERROR, - "failed to fetch volume file (key:%s)", - ctx->cmd_args.volfile_id); - break; - - } + if (ret && ctx && (ctx->active == NULL)) { + /* Do it only for the first time */ + /* Exit the process.. there is some wrong options */ + gf_log ("mgmt", GF_LOG_ERROR, + "failed to fetch volume file (key:%s)", + ctx->cmd_args.volfile_id); + cleanup_and_exit (0); } if (is_mgmt_rpc_reconnect) glusterfs_mgmt_pmap_signin (ctx); - break; default: break; } - if (need_term) { - emancipate (ctx, emval); - cleanup_and_exit (1); - } - return 0; } diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index e3285658a99..053a7c2461a 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -387,7 +387,7 @@ err: xlator_destroy (master); } - return 1; + return -1; } @@ -865,16 +865,6 @@ reincarnate (int signum) return; } -void -emancipate (glusterfs_ctx_t *ctx, int ret) -{ - /* break free from the parent */ - if (ctx->daemon_pipe[1] != -1) { - write (ctx->daemon_pipe[1], (void *) &ret, sizeof (ret)); - close (ctx->daemon_pipe[1]); - ctx->daemon_pipe[1] = -1; - } -} static char * generate_uuid () @@ -1466,7 +1456,6 @@ daemonize (glusterfs_ctx_t *ctx) int ret = -1; cmd_args_t *cmd_args = NULL; int cstatus = 0; - int err = 0; cmd_args = &ctx->cmd_args; @@ -1480,36 +1469,15 @@ daemonize (glusterfs_ctx_t *ctx) if (cmd_args->debug_mode) goto postfork; - ret = pipe (ctx->daemon_pipe); - if (ret) { - /* If pipe() fails, retain daemon_pipe[] = {-1, -1} - and parent will just not wait for child status - */ - ctx->daemon_pipe[0] = -1; - ctx->daemon_pipe[1] = -1; - } - ret = os_daemon_return (0, 0); switch (ret) { case -1: - if (ctx->daemon_pipe[0] != -1) { - close (ctx->daemon_pipe[0]); - close (ctx->daemon_pipe[1]); - } - gf_log ("daemonize", GF_LOG_ERROR, "Daemonization failed: %s", strerror(errno)); goto out; case 0: - /* child */ - /* close read */ - close (ctx->daemon_pipe[0]); break; default: - /* parent */ - /* close write */ - close (ctx->daemon_pipe[1]); - if (ctx->mtab_pid > 0) { ret = waitpid (ctx->mtab_pid, &cstatus, 0); if (!(ret == ctx->mtab_pid && cstatus == 0)) { @@ -1518,10 +1486,7 @@ daemonize (glusterfs_ctx_t *ctx) exit (1); } } - - err = 1; - read (ctx->daemon_pipe[0], (void *)&err, sizeof (err)); - _exit (err); + _exit (0); } postfork: @@ -1603,8 +1568,7 @@ glusterfs_volumes_init (glusterfs_ctx_t *ctx) if (cmd_args->volfile_server) { ret = glusterfs_mgmt_init (ctx); - /* return, do not emancipate() yet */ - return ret; + goto out; } fp = get_volfp (ctx); @@ -1621,7 +1585,6 @@ glusterfs_volumes_init (glusterfs_ctx_t *ctx) goto out; out: - emancipate (ctx, ret); return ret; } diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 64b25663595..e041ce5d6b4 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -114,9 +114,6 @@ glusterfs_ctx_init () INIT_LIST_HEAD (&glusterfs_ctx->mempool_list); ret = pthread_mutex_init (&glusterfs_ctx->lock, NULL); - glusterfs_ctx->daemon_pipe[0] = -1; - glusterfs_ctx->daemon_pipe[1] = -1; - out: return ret; } diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index fc9c062534b..a3adf151b19 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -378,7 +378,6 @@ struct _glusterfs_ctx { int mem_accounting; /* if value is other than 0, it will be set */ - int daemon_pipe[2]; }; typedef struct _glusterfs_ctx glusterfs_ctx_t; |