From cd2537541540074a5db452a49f9be220e3d76d32 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Sun, 25 Aug 2013 20:51:20 +0530 Subject: api: Set errno before invoking glfs_init_done() Change-Id: I3f4d3cfaf7078e126881111eb840d854b0b6466d BUG: 860212 Signed-off-by: Vijay Bellur Reviewed-on: http://review.gluster.org/5704 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- api/src/glfs-mgmt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'api') diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c index a76692bfd..925029d5c 100644 --- a/api/src/glfs-mgmt.c +++ b/api/src/glfs-mgmt.c @@ -416,6 +416,7 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_log (frame->this->name, GF_LOG_ERROR, "failed to get the 'volume file' from server"); ret = -1; + errno = rsp.op_errno; goto out; } @@ -481,6 +482,7 @@ out: if (ENOTSUP == ret) { gf_log ("mgmt", GF_LOG_ERROR, "Server is operating at an " "op-version which is not supported"); + errno = ENOTSUP; glfs_init_done (fs, -1); } @@ -491,8 +493,11 @@ out: gf_log ("glfs-mgmt", GF_LOG_ERROR, "failed to fetch volume file (key:%s)", ctx->cmd_args.volfile_id); - if (!need_retry) + if (!need_retry) { + if (!errno) + errno = EINVAL; glfs_init_done (fs, -1); + } } if (tmpfp) @@ -583,9 +588,10 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, gf_log ("glfs-mgmt", GF_LOG_INFO, "%d connect attempts left", cmd_args->max_connect_attempts); - if (0 >= cmd_args->max_connect_attempts) + if (0 >= cmd_args->max_connect_attempts) { + errno = ENOTCONN; glfs_init_done (fs, -1); - break; + } } break; case RPC_CLNT_CONNECT: @@ -594,10 +600,11 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, ret = glfs_volfile_fetch (fs); if (ret && ctx && (ctx->active == NULL)) { /* Do it only for the first time */ - /* Exit the process.. there is some wrong options */ + /* Exit the process.. there are some wrong options */ gf_log ("glfs-mgmt", GF_LOG_ERROR, "failed to fetch volume file (key:%s)", ctx->cmd_args.volfile_id); + errno = EINVAL; glfs_init_done (fs, -1); } -- cgit