summaryrefslogtreecommitdiffstats
path: root/transport
diff options
context:
space:
mode:
authorAnand V. Avati <avati@amp.gluster.com>2009-04-18 01:09:31 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-04-18 01:09:31 +0530
commit307528ef9a33a4d294b3ea49bbf5f0b16b27aa0f (patch)
tree08aecf95d4615ea05dc1c78aacef5950dd647901 /transport
parent50b2291e3b046ea6b8fdfcb7e206c772eae64f0e (diff)
disconnect transport peer if system is out of memory while allocating iobuf
Diffstat (limited to 'transport')
-rw-r--r--transport/ib-verbs/src/ib-verbs.c14
-rw-r--r--transport/socket/src/socket.c16
2 files changed, 26 insertions, 4 deletions
diff --git a/transport/ib-verbs/src/ib-verbs.c b/transport/ib-verbs/src/ib-verbs.c
index 5933e50..dc5ae11 100644
--- a/transport/ib-verbs/src/ib-verbs.c
+++ b/transport/ib-verbs/src/ib-verbs.c
@@ -525,6 +525,13 @@ ib_verbs_receive (transport_t *this, char **hdr_p, size_t *hdrlen_p,
if (size1) {
hdr = CALLOC (1, size1);
+ if (!hdr) {
+ gf_log (this->xl->name, GF_LOG_ERROR,
+ "unable to allocate header for peer %s",
+ this->peerinfo.identifier);
+ ret = -ENOMEM;
+ goto err;
+ }
memcpy (hdr, copy_from, size1);
copy_from += size1;
*hdr_p = hdr;
@@ -533,6 +540,13 @@ ib_verbs_receive (transport_t *this, char **hdr_p, size_t *hdrlen_p,
if (size2) {
iobuf = iobuf_get (this->xl->ctx->iobuf_pool);
+ if (!iobuf) {
+ gf_log (this->xl->name, GF_LOG_ERROR,
+ "unable to allocate IO buffer for peer %s",
+ this->peerinfo.identifier);
+ ret = -ENOMEM;
+ goto err;
+ }
memcpy (iobuf->ptr, copy_from, size2);
*iobuf_p = iobuf;
}
diff --git a/transport/socket/src/socket.c b/transport/socket/src/socket.c
index 4c9338b..b37c490 100644
--- a/transport/socket/src/socket.c
+++ b/transport/socket/src/socket.c
@@ -510,6 +510,7 @@ __socket_proto_state_machine (transport_t *this)
size_t size2 = 0;
int previous_state = -1;
struct socket_header *hdr = NULL;
+ struct iobuf *iobuf = NULL;
priv = this->private;
@@ -592,10 +593,17 @@ __socket_proto_state_machine (transport_t *this)
if (size2) {
/* TODO: sanity check size2 < page size
*/
- priv->incoming.iobuf =
- iobuf_get (this->xl->ctx->iobuf_pool);
- priv->incoming.buf_p =
- priv->incoming.iobuf->ptr;
+ iobuf = iobuf_get (this->xl->ctx->iobuf_pool);
+ if (!iobuf) {
+ gf_log (this->xl->name, GF_LOG_ERROR,
+ "unable to allocate IO buffer "
+ "for peer %s",
+ this->peerinfo.identifier);
+ ret = -ENOMEM;
+ goto unlock;
+ }
+ priv->incoming.iobuf = iobuf;
+ priv->incoming.buf_p = iobuf->ptr;
}
priv->incoming.vector[0].iov_base =