summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-03-16 09:40:06 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-17 11:57:51 -0700
commite02171f1b86cfb3cd365c4c47edc83b8230985bd (patch)
tree7e7bf4a32153b4c1e512e0e6f9ea1e28958c0532 /rpc
parent02d8dcbb5c7483ade3dd052d75e6430cb0253d1f (diff)
rpc-transport: log enhancement
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2346 (Log message enhancements in GlusterFS - phase 1) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-transport/rdma/src/name.c9
-rw-r--r--rpc/rpc-transport/rdma/src/rdma.c105
-rw-r--r--rpc/rpc-transport/socket/src/name.c21
-rw-r--r--rpc/rpc-transport/socket/src/socket.c254
4 files changed, 187 insertions, 202 deletions
diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c
index 3a8ce9d4350..bc9b97e90c3 100644
--- a/rpc/rpc-transport/rdma/src/name.c
+++ b/rpc/rpc-transport/rdma/src/name.c
@@ -360,8 +360,7 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this,
listen_host_data = dict_get (options,
"transport.rdma.bind-address");
- if (listen_port_data)
- {
+ if (listen_port_data) {
listen_port = data_to_uint16 (listen_port_data);
} else {
if (addr->sa_family == AF_INET6) {
@@ -383,8 +382,7 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this,
listen_port = GF_DEFAULT_RDMA_LISTEN_PORT;
- if (listen_host_data)
- {
+ if (listen_host_data) {
listen_host = data_to_str (listen_host_data);
}
@@ -398,8 +396,7 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this,
ret = getaddrinfo(listen_host, service, &hints, &res);
if (ret != 0) {
- gf_log (this->name,
- GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_ERROR,
"getaddrinfo failed for host %s, service %s (%s)",
listen_host, service, gai_strerror (ret));
ret = -1;
diff --git a/rpc/rpc-transport/rdma/src/rdma.c b/rpc/rpc-transport/rdma/src/rdma.c
index 81e6e3cf632..177730f65a0 100644
--- a/rpc/rpc-transport/rdma/src/rdma.c
+++ b/rpc/rpc-transport/rdma/src/rdma.c
@@ -84,8 +84,8 @@ ib_check_active_port (struct ibv_context *ctx, uint8_t port)
const char *state_str = NULL;
if (!ctx) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR,
- "Error in supplied context");
+ gf_log_callingfn (RDMA_LOG_NAME, GF_LOG_ERROR,
+ "Error in supplied context");
return -1;
}
@@ -117,8 +117,8 @@ ib_get_active_port (struct ibv_context *ib_ctx)
uint8_t ib_port = 0;
if (!ib_ctx) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR,
- "Error in supplied context");
+ gf_log_callingfn (RDMA_LOG_NAME, GF_LOG_ERROR,
+ "Error in supplied context");
return -1;
}
if (ibv_query_device (ib_ctx, &ib_device_attr)) {
@@ -176,7 +176,6 @@ rdma_new_post (rdma_device_t *device, int32_t len, rdma_post_type_t type)
post = (rdma_post_t *) GF_CALLOC (1, sizeof (*post),
gf_common_mt_rdma_post_t);
if (post == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
goto out;
}
@@ -186,7 +185,7 @@ rdma_new_post (rdma_device_t *device, int32_t len, rdma_post_type_t type)
post->buf = valloc (len);
if (!post->buf) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
+ gf_log_nomem (RDMA_LOG_NAME, GF_LOG_ERROR, len);
goto out;
}
@@ -195,7 +194,7 @@ rdma_new_post (rdma_device_t *device, int32_t len, rdma_post_type_t type)
post->buf_size,
IBV_ACCESS_LOCAL_WRITE);
if (!post->mr) {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_ERROR,
"memory registration failed");
goto out;
}
@@ -325,8 +324,7 @@ __rdma_disconnect (rpc_transport_t *this)
if (priv->connected || priv->tcp_connected) {
fcntl (priv->sock, F_SETFL, O_NONBLOCK);
if (shutdown (priv->sock, SHUT_RDWR) != 0) {
- gf_log (RDMA_LOG_NAME,
- GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
"shutdown () - error: %s",
strerror (errno));
ret = -errno;
@@ -404,6 +402,8 @@ __rdma_send_error (rdma_peer_t *peer, rdma_ioq_t *entry, rdma_post_t *post,
len = __rdma_encode_error (peer, reply_info, entry->rpchdr,
(uint32_t *)post->buf, err);
if (len == -1) {
+ gf_log (RDMA_LOG_NAME, GF_LOG_ERROR,
+ "encode error returned -1");
goto out;
}
@@ -413,7 +413,7 @@ __rdma_send_error (rdma_peer_t *peer, rdma_ioq_t *entry, rdma_post_t *post,
if (!ret) {
ret = len;
} else {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING,
"rdma_post_send (to %s) failed with ret = %d (%s)",
peer->trans->peerinfo.identifier, ret,
(ret > 0) ? strerror (ret) : "");
@@ -441,10 +441,11 @@ __rdma_create_read_chunks_from_vector (rdma_peer_t *peer,
rdma_read_chunk_t *readch = NULL;
int32_t ret = -1;
- if ((peer == NULL) || (readch_ptr == NULL) || (*readch_ptr == NULL)
- || (request_ctx == NULL) || (vector == NULL)) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, peer, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, readch_ptr, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, *readch_ptr, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, request_ctx, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, vector, out);
priv = peer->trans->private;
device = priv->device;
@@ -458,7 +459,7 @@ __rdma_create_read_chunks_from_vector (rdma_peer_t *peer,
vector[i].iov_len,
IBV_ACCESS_REMOTE_READ);
if (!mr) {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_ERROR,
"memory registration failed");
goto out;
}
@@ -493,10 +494,11 @@ __rdma_create_read_chunks (rdma_peer_t *peer, rdma_ioq_t *entry,
rdma_private_t *priv = NULL;
int pos = 0;
- if ((peer == NULL) || (entry == NULL) || (ptr == NULL)
- || (*ptr == NULL) || (request_ctx == NULL)) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, peer, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, entry, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, ptr, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, *ptr, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, request_ctx, out);
priv = peer->trans->private;
device = priv->device;
@@ -579,10 +581,11 @@ __rdma_create_write_chunks_from_vector (rdma_peer_t *peer,
rdma_write_chunk_t *writech = NULL;
int32_t ret = -1;
- if ((peer == NULL) || (writech_ptr == NULL) || (*writech_ptr == NULL)
- || (request_ctx == NULL) || (vector == NULL)) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, peer, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, writech_ptr, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, *writech_ptr, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, request_ctx, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, vector, out);
writech = *writech_ptr;
@@ -595,7 +598,7 @@ __rdma_create_write_chunks_from_vector (rdma_peer_t *peer,
IBV_ACCESS_REMOTE_WRITE
| IBV_ACCESS_LOCAL_WRITE);
if (!mr) {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_ERROR,
"memory registration failed");
goto out;
}
@@ -626,15 +629,16 @@ __rdma_create_write_chunks (rdma_peer_t *peer, rdma_ioq_t *entry,
int32_t ret = -1;
rdma_write_array_t *warray = NULL;
- if ((peer == NULL) || (entry == NULL) || (ptr == NULL)
- || (*ptr == NULL) || (request_ctx == NULL)) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, peer, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, ptr, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, *ptr, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, request_ctx, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, entry, out);
if ((chunk_type == rdma_replych)
&& ((entry->msg.request.rsphdr_count != 1) ||
(entry->msg.request.rsphdr_vec[0].iov_base == NULL))) {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING,
(entry->msg.request.rsphdr_count == 1)
? "chunktype specified as reply chunk but the vector "
"specifying the buffer to be used for holding reply"
@@ -942,14 +946,14 @@ __rdma_ioq_churn_request (rdma_peer_t *peer, rdma_ioq_t *entry,
uint32_t prog_payload_length = 0, len = 0;
struct rpc_req *rpc_req = NULL;
- if ((peer == NULL) || (entry == NULL) || (post == NULL)) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, peer, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, entry, out);
+ GF_VALIDATE_OR_GOTO (RDMA_LOG_NAME, post, out);
if ((entry->msg.request.rsphdr_count != 0)
&& (entry->msg.request.rsp_payload_count != 0)) {
ret = -1;
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING,
"both write-chunklist and reply-chunk cannot be "
"present");
goto out;
@@ -1001,7 +1005,7 @@ __rdma_ioq_churn_request (rdma_peer_t *peer, rdma_ioq_t *entry,
if (chunk_count > RDMA_MAX_SEGMENTS) {
ret = -1;
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING,
"chunk count(%d) exceeding maximum allowed RDMA "
"segment count(%d)", chunk_count, RDMA_MAX_SEGMENTS);
goto out;
@@ -1011,7 +1015,6 @@ __rdma_ioq_churn_request (rdma_peer_t *peer, rdma_ioq_t *entry,
request_ctx = mem_get (priv->device->request_ctx_pool);
if (request_ctx == NULL) {
ret = -1;
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
goto out;
}
@@ -1093,7 +1096,7 @@ __rdma_ioq_churn_request (rdma_peer_t *peer, rdma_ioq_t *entry,
if (!ret) {
ret = len;
} else {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING,
"rdma_post_send (to %s) failed with ret = %d (%s)",
peer->trans->peerinfo.identifier, ret,
(ret > 0) ? strerror (ret) : "");
@@ -1202,7 +1205,7 @@ __rdma_send_reply_inline (rdma_peer_t *peer, rdma_ioq_t *entry,
if (!ret) {
ret = send_size;
} else {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING,
"rdma_post_send (to %s) failed with ret = %d (%s)",
peer->trans->peerinfo.identifier, ret,
(ret > 0) ? strerror (ret) : "");
@@ -1337,7 +1340,6 @@ __rdma_write (rdma_peer_t *peer, rdma_post_t *post, struct iovec *vec,
sg_list = GF_CALLOC (num_sge, sizeof (struct ibv_sge), gf_common_mt_sge);
if (sg_list == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
ret = -1;
goto out;
}
@@ -1368,7 +1370,7 @@ __rdma_write (rdma_peer_t *peer, rdma_post_t *post, struct iovec *vec,
ret = ibv_post_send(peer->qp, &wr, &bad_wr);
if (ret) {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG, "rdma write to "
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING, "rdma write to "
"client (%s) failed with ret = %d (%s)",
peer->trans->peerinfo.identifier, ret,
(ret > 0) ? strerror (ret) : "");
@@ -1486,7 +1488,7 @@ __rdma_send_reply_type_nomsg (rdma_peer_t *peer, rdma_ioq_t *entry,
ret = rdma_post_send (peer->qp, post, (buf - post->buf));
if (ret) {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING,
"rdma_post_send to client (%s) failed with "
"ret = %d (%s)", peer->trans->peerinfo.identifier, ret,
(ret > 0) ? strerror (ret) : "");
@@ -1520,7 +1522,7 @@ __rdma_send_reply_type_msg (rdma_peer_t *peer, rdma_ioq_t *entry,
+ GLUSTERFS_RDMA_MAX_HEADER_SIZE;
if (send_size > GLUSTERFS_RDMA_INLINE_THRESHOLD) {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING,
"client has provided only write chunks, but the "
"combined size of rpc and program header (%d) is "
"exceeding the size of msg that can be sent using "
@@ -1572,7 +1574,7 @@ __rdma_send_reply_type_msg (rdma_peer_t *peer, rdma_ioq_t *entry,
ret = rdma_post_send (peer->qp, post, (ptr - post->buf));
if (ret) {
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING,
"rdma send to client (%s) failed with ret = %d (%s)",
peer->trans->peerinfo.identifier, ret,
(ret > 0) ? strerror (ret) : "");
@@ -1615,7 +1617,6 @@ rdma_reply_info_alloc (rdma_peer_t *peer)
reply_info = mem_get (priv->device->reply_info_pool);
if (reply_info == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
goto out;
}
@@ -1659,7 +1660,7 @@ __rdma_ioq_churn_reply (rdma_peer_t *peer, rdma_ioq_t *entry, rdma_post_t *post)
break;
default:
- gf_log (RDMA_LOG_NAME, GF_LOG_DEBUG,
+ gf_log (RDMA_LOG_NAME, GF_LOG_WARNING,
"invalid chunktype (%d) specified for sending reply",
type);
break;
@@ -1800,7 +1801,6 @@ rdma_ioq_new (rpc_transport_t *this, rpc_transport_data_t *data)
/* TODO: use mem-pool */
entry = mem_get (priv->device->ioq_pool);
if (entry == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
goto out;
}
memset (entry, 0, sizeof (*entry));
@@ -2145,7 +2145,6 @@ rdma_register_peer (rdma_device_t *device,
ent = (struct _qpent *) GF_CALLOC (1, sizeof (*ent),
gf_common_mt_qpent);
if (ent == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
goto unlock;
}
@@ -2626,7 +2625,6 @@ rdma_get_write_chunklist (char **ptr, rdma_write_array_t **write_ary)
to = GF_CALLOC (1, size, gf_common_mt_char);
if (to == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
ret = -1;
goto out;
}
@@ -2709,14 +2707,12 @@ rdma_decode_error_msg (rdma_peer_t *peer, rdma_post_t *post,
iobuf = iobuf_get (peer->trans->ctx->iobuf_pool);
if (iobuf == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
ret = -1;
goto out;
}
post->ctx.iobref = iobref = iobref_new ();
if (iobref == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
ret = -1;
goto out;
}
@@ -2817,7 +2813,6 @@ rdma_decode_msg (rdma_peer_t *peer, rdma_post_t *post,
if (header->rm_type != RDMA_NOMSG) {
post->ctx.hdr_iobuf = iobuf_get (peer->trans->ctx->iobuf_pool);
if (post->ctx.hdr_iobuf == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
ret = -1;
goto out;
}
@@ -2969,7 +2964,6 @@ rdma_do_reads (rdma_peer_t *peer, rdma_post_t *post, rdma_read_chunk_t *readch)
iobuf = iobuf_get (peer->trans->ctx->iobuf_pool);
if (iobuf == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
goto out;
}
@@ -2977,7 +2971,6 @@ rdma_do_reads (rdma_peer_t *peer, rdma_post_t *post, rdma_read_chunk_t *readch)
post->ctx.iobref = iobref_new ();
if (post->ctx.iobref == NULL) {
iobuf_unref (iobuf);
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
goto out;
}
}
@@ -3045,7 +3038,6 @@ rdma_pollin_notify (rdma_peer_t *peer, rdma_post_t *post)
if (post->ctx.iobref == NULL) {
post->ctx.iobref = iobref_new ();
if (post->ctx.iobref == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
goto out;
}
@@ -3064,7 +3056,6 @@ rdma_pollin_notify (rdma_peer_t *peer, rdma_post_t *post)
post->ctx.iobref,
post->ctx.reply_info);
if (pollin == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
goto out;
}
@@ -3699,7 +3690,6 @@ rdma_get_device (rpc_transport_t *this,
trav = GF_CALLOC (1, sizeof (*trav),
gf_common_mt_rdma_device_t);
if (trav == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
return NULL;
}
@@ -3723,21 +3713,18 @@ rdma_get_device (rpc_transport_t *this,
trav->request_ctx_pool = mem_pool_new (rdma_request_context_t,
RDMA_POOL_SIZE);
if (trav->request_ctx_pool == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
return NULL;
}
trav->ioq_pool = mem_pool_new (rdma_ioq_t, RDMA_POOL_SIZE);
if (trav->ioq_pool == NULL) {
mem_pool_destroy (trav->request_ctx_pool);
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
return NULL;
}
trav->reply_info_pool = mem_pool_new (rdma_reply_info_t,
RDMA_POOL_SIZE);
if (trav->reply_info_pool == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
mem_pool_destroy (trav->request_ctx_pool);
mem_pool_destroy (trav->ioq_pool);
return NULL;
@@ -4646,7 +4633,6 @@ rdma_server_event_handler (int fd, int idx, void *data,
this = GF_CALLOC (1, sizeof (rpc_transport_t),
gf_common_mt_rpc_transport_t);
if (this == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
return -1;
}
@@ -4655,7 +4641,6 @@ rdma_server_event_handler (int fd, int idx, void *data,
priv = GF_CALLOC (1, sizeof (rdma_private_t),
gf_common_mt_rdma_private_t);
if (priv == NULL) {
- gf_log (RDMA_LOG_NAME, GF_LOG_ERROR, "out of memory");
GF_FREE (priv);
return -1;
}
diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c
index 740f457845e..9cda665fec3 100644
--- a/rpc/rpc-transport/socket/src/name.c
+++ b/rpc/rpc-transport/socket/src/name.c
@@ -126,6 +126,8 @@ client_fill_address_family (rpc_transport_t *this, sa_family_t *sa_family)
int32_t ret = -1;
if (sa_family == NULL) {
+ gf_log_callingfn ("", GF_LOG_WARNING,
+ "sa_family argument is NULL");
goto out;
}
@@ -469,12 +471,9 @@ socket_client_get_remote_sockaddr (rpc_transport_t *this,
{
int32_t ret = 0;
- if ((sockaddr == NULL) || (sockaddr_len == NULL)
- || (sa_family == NULL)) {
- ret = -1;
- goto err;
- }
-
+ GF_VALIDATE_OR_GOTO ("socket", sockaddr, err);
+ GF_VALIDATE_OR_GOTO ("socket", sockaddr_len, err);
+ GF_VALIDATE_OR_GOTO ("socket", sa_family, err);
ret = client_fill_address_family (this, &sockaddr->sa_family);
if (ret) {
@@ -522,9 +521,7 @@ server_fill_address_family (rpc_transport_t *this, sa_family_t *sa_family)
data_t *address_family_data = NULL;
int32_t ret = -1;
- if (sa_family == NULL) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO ("socket", sa_family, out);
address_family_data = dict_get (this->options,
"transport.address-family");
@@ -566,9 +563,9 @@ socket_server_get_local_sockaddr (rpc_transport_t *this, struct sockaddr *addr,
{
int32_t ret = -1;
- if ((addr == NULL) || (addr_len == NULL) || (sa_family == NULL)) {
- goto err;
- }
+ GF_VALIDATE_OR_GOTO ("socket", sa_family, err);
+ GF_VALIDATE_OR_GOTO ("socket", addr, err);
+ GF_VALIDATE_OR_GOTO ("socket", addr_len, err);
ret = server_fill_address_family (this, &addr->sa_family);
if (ret == -1) {
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 5744ce29ad2..87430d22aae 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -124,7 +124,7 @@
&priv->incoming.pending_count, \
&bytes_read); \
if (ret == -1) { \
- gf_log (this->name, GF_LOG_TRACE, \
+ gf_log (this->name, GF_LOG_WARNING, \
"reading from socket failed. Error (%s), " \
"peer (%s)", strerror (errno), \
this->peerinfo.identifier); \
@@ -155,8 +155,8 @@ __socket_rwv (rpc_transport_t *this, struct iovec *vector, int count,
int opcount = 0;
int moved = 0;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
sock = priv->sock;
@@ -189,7 +189,7 @@ __socket_rwv (rpc_transport_t *this, struct iovec *vector, int count,
if (ret == 0) {
/* Mostly due to 'umount' in client */
- gf_log (this->name, GF_LOG_TRACE,
+ gf_log (this->name, GF_LOG_DEBUG,
"EOF from peer %s", this->peerinfo.identifier);
opcount = -1;
errno = ENOTCONN;
@@ -199,7 +199,7 @@ __socket_rwv (rpc_transport_t *this, struct iovec *vector, int count,
if (errno == EINTR)
continue;
- gf_log (this->name, GF_LOG_TRACE,
+ gf_log (this->name, GF_LOG_WARNING,
"%s failed (%s)", write ? "writev" : "readv",
strerror (errno));
opcount = -1;
@@ -273,16 +273,15 @@ __socket_disconnect (rpc_transport_t *this)
socket_private_t *priv = NULL;
int ret = -1;
- if (!this || !this->private)
- goto out;
-
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
if (priv->sock != -1) {
ret = shutdown (priv->sock, SHUT_RDWR);
priv->connected = -1;
- gf_log (this->name, GF_LOG_TRACE,
+ gf_log (this->name, GF_LOG_INFO,
"shutdown() returned %d. set connection state to -1",
ret);
}
@@ -301,8 +300,8 @@ __socket_server_bind (rpc_transport_t *this)
int reuse_check_sock = -1;
struct sockaddr_storage unix_addr = {0};
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -314,6 +313,7 @@ __socket_server_bind (rpc_transport_t *this)
"setsockopt() for SO_REUSEADDR failed (%s)",
strerror (errno));
}
+
//reuse-address doesnt work for unix type sockets
if (AF_UNIX == SA (&this->myinfo.sockaddr)->sa_family) {
memcpy (&unix_addr, SA (&this->myinfo.sockaddr),
@@ -385,8 +385,11 @@ __socket_keepalive (int fd, int keepalive_intvl, int keepalive_idle)
int ret = -1;
ret = setsockopt (fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on));
- if (ret == -1)
+ if (ret == -1) {
+ gf_log ("socket", GF_LOG_WARNING,
+ "failed to set keep alive option on socket %d", fd);
goto err;
+ }
if (keepalive_intvl == GF_USE_DEFAULT_KEEPALIVE)
goto done;
@@ -399,18 +402,26 @@ __socket_keepalive (int fd, int keepalive_intvl, int keepalive_idle)
ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPALIVE, &keepalive_intvl,
sizeof (keepalive_intvl));
#endif
- if (ret == -1)
+ if (ret == -1) {
+ gf_log ("socket", GF_LOG_WARNING,
+ "failed to set keep alive interval on socket %d", fd);
goto err;
+ }
#else
ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPIDLE, &keepalive_idle,
sizeof (keepalive_intvl));
- if (ret == -1)
+ if (ret == -1) {
+ gf_log ("socket", GF_LOG_WARNING,
+ "failed to set keep idle on socket %d", fd);
goto err;
-
+ }
ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPINTVL, &keepalive_intvl,
sizeof (keepalive_intvl));
- if (ret == -1)
+ if (ret == -1) {
+ gf_log ("socket", GF_LOG_WARNING,
+ "failed to set keep alive interval on socket %d", fd);
goto err;
+ }
#endif
done:
@@ -445,8 +456,8 @@ __socket_reset (rpc_transport_t *this)
{
socket_private_t *priv = NULL;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -507,8 +518,7 @@ __socket_ioq_new (rpc_transport_t *this, rpc_transport_msg_t *msg)
int count = 0;
uint32_t size = 0;
- if (!this)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
/* TODO: use mem-pool */
entry = GF_CALLOC (1, sizeof (*entry), gf_common_mt_ioq);
@@ -571,8 +581,7 @@ out:
void
__socket_ioq_entry_free (struct ioq *entry)
{
- if (!entry)
- return;
+ GF_VALIDATE_OR_GOTO ("socket", entry, out);
list_del_init (&entry->list);
if (entry->iobref)
@@ -580,6 +589,9 @@ __socket_ioq_entry_free (struct ioq *entry)
/* TODO: use mem-pool */
GF_FREE (entry);
+
+out:
+ return;
}
@@ -589,8 +601,8 @@ __socket_ioq_flush (rpc_transport_t *this)
socket_private_t *priv = NULL;
struct ioq *entry = NULL;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -631,8 +643,8 @@ __socket_ioq_churn (rpc_transport_t *this)
int ret = 0;
struct ioq *entry = NULL;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -663,8 +675,8 @@ socket_event_poll_err (rpc_transport_t *this)
socket_private_t *priv = NULL;
int ret = -1;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -688,8 +700,8 @@ socket_event_poll_out (rpc_transport_t *this)
socket_private_t *priv = NULL;
int ret = -1;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -720,8 +732,8 @@ __socket_read_simple_msg (rpc_transport_t *this)
uint32_t remaining_size = 0;
size_t bytes_read = 0;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -753,7 +765,7 @@ __socket_read_simple_msg (rpc_transport_t *this)
}
if (ret == -1) {
- gf_log (this->name, GF_LOG_TRACE,
+ gf_log (this->name, GF_LOG_WARNING,
"reading from socket failed. Error (%s), "
"peer (%s)", strerror (errno),
this->peerinfo.identifier);
@@ -804,8 +816,8 @@ __socket_read_vectored_request (rpc_transport_t *this)
uint32_t gluster_write_proc_len = 0;
gfs3_write_req write_req = {{0,},};
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -843,7 +855,7 @@ __socket_read_vectored_request (rpc_transport_t *this)
&write_req);
if (gluster_write_proc_len == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_ERROR,
"xdr_sizeof on gfs3_write_req failed");
ret = -1;
goto out;
@@ -871,10 +883,6 @@ __socket_read_vectored_request (rpc_transport_t *this)
if (priv->incoming.payload_vector.iov_base == NULL) {
iobuf = iobuf_get (this->ctx->iobuf_pool);
if (!iobuf) {
- gf_log (this->name, GF_LOG_ERROR,
- "unable to allocate IO buffer "
- "for peer %s",
- this->peerinfo.identifier);
ret = -1;
break;
}
@@ -882,8 +890,6 @@ __socket_read_vectored_request (rpc_transport_t *this)
if (priv->incoming.iobref == NULL) {
priv->incoming.iobref = iobref_new ();
if (priv->incoming.iobref == NULL) {
- gf_log (this->name, GF_LOG_ERROR,
- "out of memory");
ret = -1;
iobuf_unref (iobuf);
break;
@@ -949,8 +955,8 @@ __socket_read_request (rpc_transport_t *this)
int ret = -1;
char *buf = NULL;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -1015,8 +1021,8 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this)
uint32_t gluster_read_rsp_hdr_len = 0;
gfs3_read_rsp read_rsp = {0, };
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -1027,7 +1033,7 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this)
&read_rsp);
if (gluster_read_rsp_hdr_len == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_ERROR,
"xdr_sizeof on gfs3_read_rsp failed");
ret = -1;
goto out;
@@ -1102,8 +1108,8 @@ __socket_read_accepted_reply (rpc_transport_t *this)
uint32_t verflen = 0, len = 0;
uint32_t remaining_size = 0;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -1203,8 +1209,8 @@ __socket_read_vectored_reply (rpc_transport_t *this)
char *buf = NULL;
uint32_t remaining_size = 0;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -1278,8 +1284,8 @@ __socket_read_reply (rpc_transport_t *this)
rpc_request_info_t *request_info = NULL;
char map_xid = 0;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -1290,7 +1296,6 @@ __socket_read_reply (rpc_transport_t *this)
sizeof (*request_info),
gf_common_mt_rpc_trans_reqinfo_t);
if (priv->incoming.request_info == NULL) {
- gf_log (this->name, GF_LOG_ERROR, "out of memory");
goto out;
}
@@ -1314,6 +1319,8 @@ __socket_read_reply (rpc_transport_t *this)
pthread_mutex_lock (&priv->lock);
if (ret == -1) {
+ gf_log ("", GF_LOG_WARNING,
+ "notify for event MAP_XID failed");
goto out;
}
}
@@ -1345,8 +1352,8 @@ __socket_read_frag (rpc_transport_t *this)
char *buf = NULL;
uint32_t remaining_size = 0;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -1437,8 +1444,8 @@ __socket_proto_state_machine (rpc_transport_t *this,
struct iobref *iobref = NULL;
struct iovec vector[2];
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
while (priv->incoming.record_state != SP_STATE_COMPLETE) {
@@ -1447,10 +1454,6 @@ __socket_proto_state_machine (rpc_transport_t *this,
case SP_STATE_NADA:
iobuf = iobuf_get (this->ctx->iobuf_pool);
if (!iobuf) {
- gf_log (this->name, GF_LOG_ERROR,
- "unable to allocate IO buffer "
- "for peer %s",
- this->peerinfo.identifier);
ret = -ENOMEM;
goto out;
}
@@ -1479,7 +1482,7 @@ __socket_proto_state_machine (rpc_transport_t *this,
&priv->incoming.pending_count,
NULL);
if (ret == -1) {
- gf_log (this->name, GF_LOG_TRACE,
+ gf_log (this->name, GF_LOG_WARNING,
"reading from socket failed. Error (%s), "
"peer (%s)", strerror (errno),
this->peerinfo.identifier);
@@ -1537,9 +1540,6 @@ __socket_proto_state_machine (rpc_transport_t *this,
if (priv->incoming.iobref == NULL) {
priv->incoming.iobref = iobref_new ();
if (priv->incoming.iobref == NULL) {
- gf_log (this->name,
- GF_LOG_ERROR,
- "out of memory");
ret = -1;
goto out;
}
@@ -1571,6 +1571,8 @@ __socket_proto_state_machine (rpc_transport_t *this,
priv->incoming.iobuf = NULL;
if (*pollin == NULL) {
+ gf_log ("", GF_LOG_WARNING,
+ "transport pollin allocation failed");
ret = -1;
goto out;
}
@@ -1584,7 +1586,7 @@ __socket_proto_state_machine (rpc_transport_t *this,
case SP_STATE_COMPLETE:
/* control should not reach here */
- gf_log (this->name, GF_LOG_DEBUG, "control reached to "
+ gf_log (this->name, GF_LOG_WARNING, "control reached to "
"SP_STATE_COMPLETE, which should not have "
"happened");
break;
@@ -1611,8 +1613,8 @@ socket_proto_state_machine (rpc_transport_t *this,
socket_private_t *priv = NULL;
int ret = 0;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -1654,8 +1656,8 @@ socket_connect_finish (rpc_transport_t *this)
rpc_transport_event_t event = 0;
char notify_rpc = 0;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -1693,7 +1695,7 @@ socket_connect_finish (rpc_transport_t *this)
SA (&this->myinfo.sockaddr),
&this->myinfo.sockaddr_len);
if (ret == -1) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_WARNING,
"getsockname on (%d) failed (%s)",
priv->sock, strerror (errno));
__socket_disconnect (this);
@@ -1728,8 +1730,9 @@ socket_event_handler (int fd, int idx, void *data,
int ret = 0;
this = data;
- if (!this || !this->private || !this->xl)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->xl, out);
THIS = this->xl;
priv = this->private;
@@ -1754,7 +1757,9 @@ socket_event_handler (int fd, int idx, void *data,
}
if ((ret < 0) || poll_err) {
- gf_log ("transport", GF_LOG_TRACE, "disconnecting now");
+ /* Logging has happened already in earlier cases */
+ gf_log ("transport", ((ret >= 0) ? GF_LOG_INFO : GF_LOG_DEBUG),
+ "disconnecting now");
socket_event_poll_err (this);
rpc_transport_unref (this);
}
@@ -1779,8 +1784,9 @@ socket_server_event_handler (int fd, int idx, void *data,
glusterfs_ctx_t *ctx = NULL;
this = data;
- if (!this || !this->private || !this->xl)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->xl, out);
THIS = this->xl;
priv = this->private;
@@ -1794,14 +1800,18 @@ socket_server_event_handler (int fd, int idx, void *data,
new_sock = accept (priv->sock, SA (&new_sockaddr),
&addrlen);
- if (new_sock == -1)
+ if (new_sock == -1) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "accept on %d failed (%s)",
+ priv->sock, strerror (errno));
goto unlock;
+ }
if (!priv->bio) {
ret = __socket_nonblock (new_sock);
if (ret == -1) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_WARNING,
"NBIO on %d failed (%s)",
new_sock, strerror (errno));
@@ -1813,7 +1823,7 @@ socket_server_event_handler (int fd, int idx, void *data,
if (priv->nodelay) {
ret = __socket_nodelay (new_sock);
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_WARNING,
"setsockopt() failed for "
"NODELAY (%s)",
strerror (errno));
@@ -1825,7 +1835,7 @@ socket_server_event_handler (int fd, int idx, void *data,
priv->keepaliveintvl,
priv->keepaliveidle);
if (ret == -1)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_WARNING,
"Failed to set keep-alive: %s",
strerror (errno));
}
@@ -1848,7 +1858,7 @@ socket_server_event_handler (int fd, int idx, void *data,
SA (&new_trans->myinfo.sockaddr),
&new_trans->myinfo.sockaddr_len);
if (ret == -1) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_WARNING,
"getsockname on %d failed (%s)",
new_sock, strerror (errno));
close (new_sock);
@@ -1883,8 +1893,11 @@ socket_server_event_handler (int fd, int idx, void *data,
ret = -1;
}
pthread_mutex_unlock (&new_priv->lock);
- if (ret == -1)
+ if (ret == -1) {
+ gf_log ("", GF_LOG_WARNING,
+ "failed to register the socket with event");
goto unlock;
+ }
ret = rpc_transport_notify (this, RPC_TRANSPORT_ACCEPT,
new_trans);
@@ -1904,8 +1917,8 @@ socket_disconnect (rpc_transport_t *this)
socket_private_t *priv = NULL;
int ret = -1;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -1931,14 +1944,14 @@ socket_connect (rpc_transport_t *this, int port)
glusterfs_ctx_t *ctx = NULL;
sa_family_t sa_family = {0, };
- if (!this || !this->private)
- goto err;
+ GF_VALIDATE_OR_GOTO ("socket", this, err);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, err);
priv = this->private;
ctx = this->ctx;
if (!priv) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log_callingfn (this->name, GF_LOG_WARNING,
"connect() called on uninitialized transport");
goto err;
}
@@ -1950,8 +1963,8 @@ socket_connect (rpc_transport_t *this, int port)
pthread_mutex_unlock (&priv->lock);
if (sock != -1) {
- gf_log (this->name, GF_LOG_TRACE,
- "connect () called on transport already connected");
+ gf_log_callingfn (this->name, GF_LOG_TRACE,
+ "connect () called on transport already connected");
ret = 0;
goto err;
}
@@ -2070,8 +2083,11 @@ socket_connect (rpc_transport_t *this, int port)
priv->idx = event_register (ctx->event_pool, priv->sock,
socket_event_handler, this, 1, 1);
- if (priv->idx == -1)
+ if (priv->idx == -1) {
+ gf_log ("", GF_LOG_WARNING,
+ "failed to register the event");
ret = -1;
+ }
}
unlock:
pthread_mutex_unlock (&priv->lock);
@@ -2093,8 +2109,8 @@ socket_listen (rpc_transport_t *this)
glusterfs_ctx_t *ctx = NULL;
sa_family_t sa_family = {0, };
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
myinfo = &this->myinfo;
@@ -2107,8 +2123,8 @@ socket_listen (rpc_transport_t *this)
pthread_mutex_unlock (&priv->lock);
if (sock != -1) {
- gf_log (this->name, GF_LOG_DEBUG,
- "alreading listening");
+ gf_log_callingfn (this->name, GF_LOG_DEBUG,
+ "alreading listening");
return ret;
}
@@ -2208,7 +2224,7 @@ socket_listen (rpc_transport_t *this)
this, 1, 0);
if (priv->idx == -1) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_WARNING,
"could not register socket %d with events",
priv->sock);
ret = -1;
@@ -2235,8 +2251,8 @@ socket_submit_request (rpc_transport_t *this, rpc_transport_req_t *req)
struct ioq *entry = NULL;
glusterfs_ctx_t *ctx = NULL;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
ctx = this->ctx;
@@ -2245,7 +2261,7 @@ socket_submit_request (rpc_transport_t *this, rpc_transport_req_t *req)
{
if (priv->connected != 1) {
if (!priv->submit_log && !priv->connect_finish_log) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_INFO,
"not connected (priv->connected = %d)",
priv->connected);
priv->submit_log = 1;
@@ -2298,8 +2314,8 @@ socket_submit_reply (rpc_transport_t *this, rpc_transport_reply_t *reply)
struct ioq *entry = NULL;
glusterfs_ctx_t *ctx = NULL;
- if (!this || !this->private)
- goto out;
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
ctx = this->ctx;
@@ -2308,7 +2324,7 @@ socket_submit_reply (rpc_transport_t *this, rpc_transport_reply_t *reply)
{
if (priv->connected != 1) {
if (!priv->submit_log && !priv->connect_finish_log) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_log (this->name, GF_LOG_INFO,
"not connected (priv->connected = %d)",
priv->connected);
priv->submit_log = 1;
@@ -2355,9 +2371,8 @@ socket_getpeername (rpc_transport_t *this, char *hostname, int hostlen)
{
int32_t ret = -1;
- if ((this == NULL) || (hostname == NULL)) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", hostname, out);
if (hostlen < (strlen (this->peerinfo.identifier) + 1)) {
goto out;
@@ -2376,9 +2391,8 @@ socket_getpeeraddr (rpc_transport_t *this, char *peeraddr, int addrlen,
{
int32_t ret = -1;
- if ((this == NULL) || (sa == NULL)) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", sa, out);
*sa = this->peerinfo.sockaddr;
@@ -2396,9 +2410,8 @@ socket_getmyname (rpc_transport_t *this, char *hostname, int hostlen)
{
int32_t ret = -1;
- if ((this == NULL) || (hostname == NULL)) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", hostname, out);
if (hostlen < (strlen (this->myinfo.identifier) + 1)) {
goto out;
@@ -2417,9 +2430,8 @@ socket_getmyaddr (rpc_transport_t *this, char *myaddr, int addrlen,
{
int32_t ret = 0;
- if ((this == NULL) || (sa == NULL)) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", sa, out);
*sa = this->myinfo.sockaddr;
@@ -2477,11 +2489,8 @@ reconfigure (rpc_transport_t *this, dict_t *options)
char *optstr = NULL;
int ret = -1;
- if (!this || !this->private) {
- ret =-1;
- goto out;
- }
-
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
priv = this->private;
@@ -2516,16 +2525,13 @@ socket_init (rpc_transport_t *this)
uint32_t keepalive = 0;
if (this->private) {
- gf_log (this->name, GF_LOG_DEBUG,
- "double init attempted");
+ gf_log_callingfn (this->name, GF_LOG_ERROR,
+ "double init attempted");
return -1;
}
priv = GF_CALLOC (1, sizeof (*priv), gf_common_mt_socket_private_t);
if (!priv) {
- gf_log (this->name, GF_LOG_ERROR,
- "calloc (1, %"GF_PRI_SIZET") returned NULL",
- sizeof (*priv));
return -1;
}