summaryrefslogtreecommitdiffstats
path: root/transport/socket/src/socket.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-04-22 13:33:09 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-04-23 06:32:52 -0700
commit582de0677da4be19fc6f873625c58c45d069ab1c (patch)
treef10cb3e26e1f92f6ea91034e6f7bb925790dd9bc /transport/socket/src/socket.c
parent72baa17282f5cf749fa743fd601c7b728ece4fa2 (diff)
Memory accounting changes
Memory accounting Changes. Thanks to Vinayak Hegde and Csaba Henk for their contributions. Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 329 (Replacing memory allocation functions with mem-type functions) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=329
Diffstat (limited to 'transport/socket/src/socket.c')
-rw-r--r--transport/socket/src/socket.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/transport/socket/src/socket.c b/transport/socket/src/socket.c
index 28b828f29..7f7f8093a 100644
--- a/transport/socket/src/socket.c
+++ b/transport/socket/src/socket.c
@@ -273,7 +273,7 @@ __socket_reset (transport_t *this)
/* TODO: use mem-pool on incoming data */
if (priv->incoming.hdr_p)
- free (priv->incoming.hdr_p);
+ GF_FREE (priv->incoming.hdr_p);
if (priv->incoming.iobuf)
iobuf_unref (priv->incoming.iobuf);
@@ -298,7 +298,8 @@ __socket_ioq_new (transport_t *this, char *buf, int len,
priv = this->private;
/* TODO: use mem-pool */
- entry = CALLOC (1, sizeof (*entry));
+ entry = GF_CALLOC (1, sizeof (*entry),
+ gf_common_mt_ioq);
if (!entry)
return NULL;
@@ -346,10 +347,10 @@ __socket_ioq_entry_free (struct ioq *entry)
iobref_unref (entry->iobref);
/* TODO: use mem-pool */
- free (entry->buf);
+ GF_FREE (entry->buf);
/* TODO: use mem-pool */
- free (entry);
+ GF_FREE (entry);
}
@@ -607,7 +608,8 @@ __socket_proto_state_machine (transport_t *this)
priv->incoming.buflen = size2;
/* TODO: use mem-pool */
- priv->incoming.hdr_p = MALLOC (size1);
+ priv->incoming.hdr_p = GF_MALLOC (size1,
+ gf_common_mt_char);
if (size2) {
/* TODO: sanity check size2 < page size
*/
@@ -891,7 +893,8 @@ socket_server_event_handler (int fd, int idx, void *data,
}
}
- new_trans = CALLOC (1, sizeof (*new_trans));
+ new_trans = GF_CALLOC (1, sizeof (*new_trans),
+ gf_common_mt_transport_t);
new_trans->xl = this->xl;
new_trans->fini = this->fini;
@@ -1376,7 +1379,8 @@ socket_init (transport_t *this)
return -1;
}
- priv = CALLOC (1, sizeof (*priv));
+ priv = GF_CALLOC (1, sizeof (*priv),
+ gf_common_mt_socket_private_t);
if (!priv) {
gf_log (this->xl->name, GF_LOG_ERROR,
"calloc (1, %"GF_PRI_SIZET") returned NULL",
@@ -1465,9 +1469,27 @@ fini (transport_t *this)
"transport %p destroyed", this);
pthread_mutex_destroy (&priv->lock);
- FREE (priv);
+ GF_FREE (priv);
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_common_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
int32_t
init (transport_t *this)