From e02171f1b86cfb3cd365c4c47edc83b8230985bd Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Wed, 16 Mar 2011 09:40:06 +0000 Subject: rpc-transport: log enhancement Signed-off-by: Amar Tumballi Signed-off-by: Vijay Bellur BUG: 2346 (Log message enhancements in GlusterFS - phase 1) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346 --- rpc/rpc-transport/socket/src/name.c | 21 ++- rpc/rpc-transport/socket/src/socket.c | 254 +++++++++++++++++----------------- 2 files changed, 139 insertions(+), 136 deletions(-) (limited to 'rpc/rpc-transport/socket/src') 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; } -- cgit