summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilind Changire <mchangir@redhat.com>2019-02-23 18:58:48 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2019-02-25 15:23:11 +0000
commit155ebe4b5719f40b3feaf9fd8ff892cc10ad0e78 (patch)
treeecbc9f2e88f385ff6b8f7f357b1678601b520c11
parent2620dbccccb63fba66384b17b47ddd8e784e8390 (diff)
socket: socket event handlers now return void
Problem: Returning any value from socket event handlers to the event sub-system doesn't make sense since event sub-system cannot handle socket sub-system errors. Solution: Change return type of all socket event handlers to 'void' mainline: > Reviewed-on: https://review.gluster.org/c/glusterfs/+/22221 Change-Id: I70dc2c57f12b7ea2fae41120f71aa0d7fe0b2b6f Fixes: bz#1651246 Signed-off-by: Milind Changire <mchangir@redhat.com> (cherry picked from commit 776ba851c6ee6c265253d44cf1d6e4e3d4a21772)
-rw-r--r--cli/src/cli-rl.c4
-rw-r--r--libglusterfs/src/event-epoll.c7
-rw-r--r--libglusterfs/src/event-poll.c14
-rw-r--r--libglusterfs/src/event.c7
-rw-r--r--libglusterfs/src/gf-event.h4
-rw-r--r--rpc/rpc-transport/socket/src/socket.c10
6 files changed, 22 insertions, 24 deletions
diff --git a/cli/src/cli-rl.c b/cli/src/cli-rl.c
index dd0993b8646..495f9391a1a 100644
--- a/cli/src/cli-rl.c
+++ b/cli/src/cli-rl.c
@@ -102,7 +102,7 @@ cli_rl_process_line(char *line)
state->rl_processing = 0;
}
-int
+void
cli_rl_stdin(int fd, int idx, int gen, void *data, int poll_out, int poll_in,
int poll_err)
{
@@ -114,7 +114,7 @@ cli_rl_stdin(int fd, int idx, int gen, void *data, int poll_out, int poll_in,
event_handled(state->ctx->event_pool, fd, idx, gen);
- return 0;
+ return;
}
char *
diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c
index 9826cc9e275..fd1dda2cc03 100644
--- a/libglusterfs/src/event-epoll.c
+++ b/libglusterfs/src/event-epoll.c
@@ -588,10 +588,9 @@ pre_unlock:
goto out;
if (!handled_error_previously) {
- ret = handler(fd, idx, gen, data,
- (event->events & (EPOLLIN | EPOLLPRI)),
- (event->events & (EPOLLOUT)),
- (event->events & (EPOLLERR | EPOLLHUP)));
+ handler(fd, idx, gen, data, (event->events & (EPOLLIN | EPOLLPRI)),
+ (event->events & (EPOLLOUT)),
+ (event->events & (EPOLLERR | EPOLLHUP)));
}
out:
event_slot_unref(event_pool, slot, idx);
diff --git a/libglusterfs/src/event-poll.c b/libglusterfs/src/event-poll.c
index 727d2a000a2..8ccd1f7f600 100644
--- a/libglusterfs/src/event-poll.c
+++ b/libglusterfs/src/event-poll.c
@@ -35,7 +35,7 @@ event_register_poll(struct event_pool *event_pool, int fd,
event_handler_t handler, void *data, int poll_in,
int poll_out);
-static int
+static void
__flush_fd(int fd, int idx, int gen, void *data, int poll_in, int poll_out,
int poll_err)
{
@@ -43,7 +43,7 @@ __flush_fd(int fd, int idx, int gen, void *data, int poll_in, int poll_out,
int ret = -1;
if (!poll_in)
- return ret;
+ return;
do {
ret = sys_read(fd, buf, 64);
@@ -55,7 +55,7 @@ __flush_fd(int fd, int idx, int gen, void *data, int poll_in, int poll_out,
}
} while (ret == 64);
- return ret;
+ return;
}
static int
@@ -375,10 +375,10 @@ unlock:
pthread_mutex_unlock(&event_pool->mutex);
if (handler)
- ret = handler(ufds[i].fd, idx, 0, data,
- (ufds[i].revents & (POLLIN | POLLPRI)),
- (ufds[i].revents & (POLLOUT)),
- (ufds[i].revents & (POLLERR | POLLHUP | POLLNVAL)));
+ handler(ufds[i].fd, idx, 0, data,
+ (ufds[i].revents & (POLLIN | POLLPRI)),
+ (ufds[i].revents & (POLLOUT)),
+ (ufds[i].revents & (POLLERR | POLLHUP | POLLNVAL)));
return ret;
}
diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c
index 5b4d43e8650..8d3d06bafc4 100644
--- a/libglusterfs/src/event.c
+++ b/libglusterfs/src/event.c
@@ -159,12 +159,12 @@ out:
return ret;
}
-int
+void
poller_destroy_handler(int fd, int idx, int gen, void *data, int poll_out,
int poll_in, int poll_err)
{
struct event_destroy_data *destroy = NULL;
- int readfd = -1, ret = -1;
+ int readfd = -1;
char buf = '\0';
destroy = data;
@@ -176,11 +176,10 @@ poller_destroy_handler(int fd, int idx, int gen, void *data, int poll_out,
while (sys_read(readfd, &buf, 1) > 0) {
}
- ret = 0;
out:
event_handled(destroy->pool, fd, idx, gen);
- return ret;
+ return;
}
/* This function destroys all the poller threads.
diff --git a/libglusterfs/src/gf-event.h b/libglusterfs/src/gf-event.h
index 5c3724cc953..49aa45d169a 100644
--- a/libglusterfs/src/gf-event.h
+++ b/libglusterfs/src/gf-event.h
@@ -22,8 +22,8 @@ struct event_data {
int gen;
} __attribute__((__packed__, __may_alias__));
-typedef int (*event_handler_t)(int fd, int idx, int gen, void *data,
- int poll_in, int poll_out, int poll_err);
+typedef void (*event_handler_t)(int fd, int idx, int gen, void *data,
+ int poll_in, int poll_out, int poll_err);
#define EVENT_EPOLL_TABLES 1024
#define EVENT_EPOLL_SLOTS 1024
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index c413b7d20ac..40d2be30782 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -2833,7 +2833,7 @@ socket_complete_connection(rpc_transport_t *this)
}
/* reads rpc_requests during pollin */
-static int
+static void
socket_event_handler(int fd, int idx, int gen, void *data, int poll_in,
int poll_out, int poll_err)
{
@@ -2883,7 +2883,7 @@ socket_event_handler(int fd, int idx, int gen, void *data, int poll_in,
if (ret > 0) {
gf_log(this->name, GF_LOG_TRACE,
"(sock:%d) returning to wait on socket", priv->sock);
- return 0;
+ return;
}
} else {
char *sock_type = (priv->is_server ? "Server" : "Client");
@@ -2938,10 +2938,10 @@ socket_event_handler(int fd, int idx, int gen, void *data, int poll_in,
}
out:
- return ret;
+ return;
}
-static int
+static void
socket_server_event_handler(int fd, int idx, int gen, void *data, int poll_in,
int poll_out, int poll_err)
{
@@ -3169,7 +3169,7 @@ socket_server_event_handler(int fd, int idx, int gen, void *data, int poll_in,
}
}
out:
- return ret;
+ return;
}
static int