summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/protocol/server/src')
-rw-r--r--xlators/protocol/server/src/server-handshake.c18
-rw-r--r--xlators/protocol/server/src/server-helpers.c17
-rw-r--r--xlators/protocol/server/src/server-mem-types.h1
-rw-r--r--xlators/protocol/server/src/server.c31
-rw-r--r--xlators/protocol/server/src/server3_1-fops.c12
5 files changed, 36 insertions, 43 deletions
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c
index 8ce9f6b3a86..bc4d4afa253 100644
--- a/xlators/protocol/server/src/server-handshake.c
+++ b/xlators/protocol/server/src/server-handshake.c
@@ -537,11 +537,12 @@ server_setvolume (rpcsvc_request_t *req)
peerinfo = &req->conn->trans->peerinfo;
- ret = dict_set_static_ptr (params, "peer-info", peerinfo);
- if (ret < 0)
- gf_log (this->name, GF_LOG_DEBUG,
- "failed to set peer-info");
-
+ if (peerinfo) {
+ ret = dict_set_static_ptr (params, "peer-info", peerinfo);
+ if (ret < 0)
+ gf_log (this->name, GF_LOG_DEBUG,
+ "failed to set peer-info");
+ }
if (conf->auth_modules == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"Authentication module not initialized");
@@ -553,7 +554,7 @@ server_setvolume (rpcsvc_request_t *req)
if (ret == AUTH_ACCEPT) {
gf_log (this->name, GF_LOG_INFO,
"accepted client from %s",
- peerinfo->identifier);
+ (peerinfo)?peerinfo->identifier:"");
op_ret = 0;
conn->bound_xl = xl;
ret = dict_set_str (reply, "ERROR", "Success");
@@ -563,7 +564,7 @@ server_setvolume (rpcsvc_request_t *req)
} else {
gf_log (this->name, GF_LOG_ERROR,
"Cannot authenticate client from %s",
- peerinfo->identifier);
+ (peerinfo)? peerinfo->identifier:"<>");
op_ret = -1;
op_errno = EACCES;
ret = dict_set_str (reply, "ERROR", "Authentication failed");
@@ -621,7 +622,8 @@ fail:
}
if (rsp.dict.dict_len) {
- rsp.dict.dict_val = GF_CALLOC (1, rsp.dict.dict_len, 0);
+ rsp.dict.dict_val = GF_CALLOC (1, rsp.dict.dict_len,
+ gf_server_mt_rsp_buf_t);
if (rsp.dict.dict_val) {
ret = dict_serialize (reply, rsp.dict.dict_val);
if (ret < 0) {
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index 44496a1592b..617a12a01fe 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -289,7 +289,7 @@ server_copy_frame (call_frame_t *frame)
new_frame = copy_frame (frame);
- new_state = GF_CALLOC (1, sizeof (server_state_t), 0);
+ new_state = GF_CALLOC (1, sizeof (server_state_t), gf_server_mt_state_t);
new_frame->root->op = frame->root->op;
new_frame->root->type = frame->root->type;
@@ -315,7 +315,7 @@ gf_add_locker (struct _lock_table *table, const char *volume,
struct _locker *new = NULL;
uint8_t dir = 0;
- new = GF_CALLOC (1, sizeof (struct _locker), 0);
+ new = GF_CALLOC (1, sizeof (struct _locker), gf_server_mt_locker_t);
if (new == NULL) {
gf_log ("server", GF_LOG_ERROR,
"failed to allocate memory for \'struct _locker\'");
@@ -455,7 +455,7 @@ gf_lock_table_new (void)
{
struct _lock_table *new = NULL;
- new = GF_CALLOC (1, sizeof (struct _lock_table), 0);
+ new = GF_CALLOC (1, sizeof (struct _lock_table), gf_server_mt_lock_table_t);
if (new == NULL) {
gf_log ("server-protocol", GF_LOG_CRITICAL,
"failed to allocate memory for new lock table");
@@ -893,7 +893,8 @@ server_connection_get (xlator_t *this, const char *id)
}
if (!conn) {
- conn = (void *) GF_CALLOC (1, sizeof (*conn), 0);
+ conn = (void *) GF_CALLOC (1, sizeof (*conn),
+ gf_server_mt_conn_t);
conn->id = gf_strdup (id);
conn->fdtable = gf_fd_fdtable_alloc ();
@@ -959,7 +960,7 @@ server_alloc_frame (rpcsvc_request_t *req)
frame = create_frame (conn->this, req->conn->svc->ctx->pool);
GF_VALIDATE_OR_GOTO("server", frame, out);
- state = GF_CALLOC (1, sizeof (*state), 0);
+ state = GF_CALLOC (1, sizeof (*state), gf_server_mt_state_t);
GF_VALIDATE_OR_GOTO("server", state, out);
if (conn->bound_xl)
@@ -1091,7 +1092,7 @@ create_server_conn_state (xlator_t *this, rpc_transport_t *xprt)
server_connection_t *conn = NULL;
int ret = -1;
- conn = GF_CALLOC (1, sizeof (*conn), 0);
+ conn = GF_CALLOC (1, sizeof (*conn), gf_server_mt_conn_t);
if (!conn)
goto out;
@@ -1400,7 +1401,7 @@ serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp)
int ret = -1;
list_for_each_entry (entry, &entries->list, list) {
- trav = GF_CALLOC (1, sizeof (*trav), 0);
+ trav = GF_CALLOC (1, sizeof (*trav), gf_server_mt_dirent_rsp_t);
if (!trav)
goto out;
@@ -1436,7 +1437,7 @@ serialize_rsp_dirent (gf_dirent_t *entries, gfs3_readdir_rsp *rsp)
int ret = -1;
list_for_each_entry (entry, &entries->list, list) {
- trav = GF_CALLOC (1, sizeof (*trav), 0);
+ trav = GF_CALLOC (1, sizeof (*trav), gf_server_mt_dirent_rsp_t);
if (!trav)
goto out;
trav->d_ino = entry->d_ino;
diff --git a/xlators/protocol/server/src/server-mem-types.h b/xlators/protocol/server/src/server-mem-types.h
index 76c5ae1ac0c..32f31fae783 100644
--- a/xlators/protocol/server/src/server-mem-types.h
+++ b/xlators/protocol/server/src/server-mem-types.h
@@ -30,6 +30,7 @@ enum gf_server_mem_types_ {
gf_server_mt_locker_t,
gf_server_mt_lock_table_t,
gf_server_mt_conn_t,
+ gf_server_mt_dirent_rsp_t,
gf_server_mt_rsp_buf_t,
gf_server_mt_volfile_ctx_t,
gf_server_mt_end,
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index b59fd513ac9..bb9edab1328 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -474,31 +474,15 @@ out:
return 0;
}
-static int32_t
-mem_acct_init (xlator_t *this)
-{
- int ret = -1;
-
- if (!this)
- return ret;
-
- ret = xlator_mem_acct_init (this, gf_server_mt_end + 1);
-
- if (ret != 0) {
- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
- "failed");
- return ret;
- }
-
- return ret;
-}
-
int
init (xlator_t *this)
{
int32_t ret = -1;
server_conf_t *conf = NULL;
+ if (!this)
+ goto out;
+
if (this->children == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"protocol/server should have subvolume");
@@ -511,11 +495,14 @@ init (xlator_t *this)
goto out;
}
- ret = mem_acct_init (this);
- if (ret)
+ ret = xlator_mem_acct_init (this, gf_server_mt_end + 1);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to Initialize memory accounting");
goto out;
+ }
- conf = GF_CALLOC (1, sizeof (server_conf_t), 0);
+ conf = GF_CALLOC (1, sizeof (server_conf_t), gf_server_mt_server_conf_t);
GF_VALIDATE_OR_GOTO(this->name, conf, out);
INIT_LIST_HEAD (&conf->conns);
diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c
index 54dda8964a0..6dee758e777 100644
--- a/xlators/protocol/server/src/server3_1-fops.c
+++ b/xlators/protocol/server/src/server3_1-fops.c
@@ -105,7 +105,8 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
if ((op_ret >= 0) && dict) {
- rsp.dict.dict_val = GF_CALLOC (1, rsp.dict.dict_len, 0);
+ rsp.dict.dict_val = GF_CALLOC (1, rsp.dict.dict_len,
+ gf_server_mt_rsp_buf_t);
if (!rsp.dict.dict_val) {
op_ret = -1;
op_errno = ENOMEM;
@@ -695,7 +696,8 @@ server_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- rsp.dict.dict_val = GF_CALLOC (len, sizeof (char), 0);
+ rsp.dict.dict_val = GF_CALLOC (len, sizeof (char),
+ gf_server_mt_rsp_buf_t);
if (!rsp.dict.dict_val) {
op_ret = -1;
op_errno = ENOMEM;
@@ -755,7 +757,7 @@ server_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
len = 0;
goto out;
}
- rsp.dict.dict_val = GF_CALLOC (1, len, 0);
+ rsp.dict.dict_val = GF_CALLOC (1, len, gf_server_mt_rsp_buf_t);
if (!rsp.dict.dict_val) {
op_ret = -1;
op_errno = ENOMEM;
@@ -1640,7 +1642,7 @@ server_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
len = 0;
goto out;
}
- rsp.dict.dict_val = GF_CALLOC (1, len, 0);
+ rsp.dict.dict_val = GF_CALLOC (1, len, gf_server_mt_rsp_buf_t);
if (!rsp.dict.dict_val) {
op_ret = -1;
op_errno = ENOMEM;
@@ -1709,7 +1711,7 @@ server_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
len = 0;
goto out;
}
- rsp.dict.dict_val = GF_CALLOC (1, len, 0);
+ rsp.dict.dict_val = GF_CALLOC (1, len, gf_server_mt_rsp_buf_t);
if (!rsp.dict.dict_val) {
op_ret = -1;
op_errno = ENOMEM;