summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-transport/socket/src/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/rpc-transport/socket/src/socket.c')
-rw-r--r--rpc/rpc-transport/socket/src/socket.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 490fe8a7e98..e3d97f7c839 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -2491,8 +2491,10 @@ socket_server_event_handler (int fd, int idx, void *data,
new_trans = GF_CALLOC (1, sizeof (*new_trans),
gf_common_mt_rpc_trans_t);
- if (!new_trans)
+ if (!new_trans) {
+ close (new_sock);
goto unlock;
+ }
ret = pthread_mutex_init(&new_trans->lock, NULL);
if (ret == -1) {
@@ -2500,6 +2502,7 @@ socket_server_event_handler (int fd, int idx, void *data,
"pthread_mutex_init() failed: %s",
strerror (errno));
close (new_sock);
+ GF_FREE (new_trans);
goto unlock;
}
@@ -2520,6 +2523,8 @@ socket_server_event_handler (int fd, int idx, void *data,
"getsockname on %d failed (%s)",
new_sock, strerror (errno));
close (new_sock);
+ GF_FREE (new_trans->name);
+ GF_FREE (new_trans);
goto unlock;
}
@@ -2527,6 +2532,8 @@ socket_server_event_handler (int fd, int idx, void *data,
ret = socket_init(new_trans);
if (ret != 0) {
close(new_sock);
+ GF_FREE (new_trans->name);
+ GF_FREE (new_trans);
goto unlock;
}
new_trans->ops = this->ops;
@@ -2549,6 +2556,8 @@ socket_server_event_handler (int fd, int idx, void *data,
gf_log(this->name,GF_LOG_ERROR,
"server setup failed");
close(new_sock);
+ GF_FREE (new_trans->name);
+ GF_FREE (new_trans);
goto unlock;
}
}
@@ -2562,6 +2571,8 @@ socket_server_event_handler (int fd, int idx, void *data,
new_sock, strerror (errno));
close (new_sock);
+ GF_FREE (new_trans->name);
+ GF_FREE (new_trans);
goto unlock;
}
}
@@ -2600,6 +2611,8 @@ socket_server_event_handler (int fd, int idx, void *data,
if (ret == -1) {
gf_log (this->name, GF_LOG_WARNING,
"failed to register the socket with event");
+ close (new_sock);
+ rpc_transport_unref (new_trans);
goto unlock;
}