summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-mgmt.c48
-rw-r--r--api/src/glfs.c14
2 files changed, 44 insertions, 18 deletions
diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c
index 6843e9cb3..afb351da0 100644
--- a/api/src/glfs-mgmt.c
+++ b/api/src/glfs-mgmt.c
@@ -236,11 +236,19 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
int ret = 0;
ssize_t size = 0;
FILE *tmpfp = NULL;
- int need_retry = 0;
+ int need_retry = 0;
struct glfs *fs = NULL;
frame = myframe;
ctx = frame->this->ctx;
+
+ if (!ctx) {
+ gf_log (frame->this->name, GF_LOG_ERROR, "NULL context");
+ errno = EINVAL;
+ ret = -1;
+ goto out;
+ }
+
fs = ((xlator_t *)ctx->master)->private;
if (-1 == req->rpc_status) {
@@ -260,7 +268,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;
+ errno = rsp.op_errno;
goto out;
}
@@ -296,7 +304,7 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
*/
ret = glusterfs_volfile_reconfigure (fs->oldvollen, tmpfp, fs->ctx,
- fs->oldvolfile);
+ fs->oldvolfile);
if (ret == 0) {
gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG,
"No need to re-load volfile, reconfigure done");
@@ -323,13 +331,13 @@ out:
if (rsp.spec)
free (rsp.spec);
- // Stop if server is running at an unsupported op-version
- 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);
- }
+ // Stop if server is running at an unsupported op-version
+ 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);
+ }
if (ret && ctx && !ctx->active) {
/* Do it only for the first time */
@@ -339,10 +347,10 @@ out:
"failed to fetch volume file (key:%s)",
ctx->cmd_args.volfile_id);
if (!need_retry) {
- if (!errno)
- errno = EINVAL;
+ if (!errno)
+ errno = EINVAL;
glfs_init_done (fs, -1);
- }
+ }
}
if (tmpfp)
@@ -420,6 +428,10 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
this = mydata;
ctx = this->ctx;
+
+ if (!ctx)
+ goto out;
+
fs = ((xlator_t *)ctx->master)->private;
cmd_args = &ctx->cmd_args;
@@ -434,22 +446,22 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
"%d connect attempts left",
cmd_args->max_connect_attempts);
if (0 >= cmd_args->max_connect_attempts) {
- errno = ENOTCONN;
+ errno = ENOTCONN;
glfs_init_done (fs, -1);
- }
+ }
}
break;
case RPC_CLNT_CONNECT:
rpc_clnt_set_connected (&((struct rpc_clnt*)ctx->mgmt)->conn);
ret = glfs_volfile_fetch (fs);
- if (ret && ctx && (ctx->active == NULL)) {
+ if (ret && (ctx->active == NULL)) {
/* Do it only for the first time */
/* 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;
+ errno = EINVAL;
glfs_init_done (fs, -1);
}
@@ -457,7 +469,7 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
default:
break;
}
-
+out:
return 0;
}
diff --git a/api/src/glfs.c b/api/src/glfs.c
index 174076e39..ea10fb55c 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -589,6 +589,13 @@ glfs_init_async (struct glfs *fs, glfs_init_cbk cbk)
{
int ret = -1;
+ if (!fs || !fs->ctx) {
+ gf_log ("glfs", GF_LOG_ERROR,
+ "fs is not properly initialized.");
+ errno = EINVAL;
+ return ret;
+ }
+
fs->init_cbk = cbk;
ret = glfs_init_common (fs);
@@ -602,6 +609,13 @@ glfs_init (struct glfs *fs)
{
int ret = -1;
+ if (!fs || !fs->ctx) {
+ gf_log ("glfs", GF_LOG_ERROR,
+ "fs is not properly initialized.");
+ errno = EINVAL;
+ return ret;
+ }
+
ret = glfs_init_common (fs);
if (ret)
return ret;