From 37773839e4eee8a753598fb01dbd06220b98dc72 Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Sat, 26 May 2018 12:36:04 +0530 Subject: rpc: conditionally cleanup event slot Problem: socket_server_event_handler() may call rpc_transport_unref() for a socket which may fail registration with the event sub-system. This causes an assert to fail in event_unregister_epoll_common() Solution: Conditionally cleanup event slot only if slot index >= 0 Change-Id: I6ca7c133712e894adc335c7763879691b7e4b213 fixes: bz#1583734 Signed-off-by: Milind Changire (cherry picked from commit 3780f6c2515c34f8705eb0fe25291bb97e73f354) --- libglusterfs/src/event-epoll.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c index 45f724ab055..c861fa721e5 100644 --- a/libglusterfs/src/event-epoll.c +++ b/libglusterfs/src/event-epoll.c @@ -404,6 +404,14 @@ event_unregister_epoll_common (struct event_pool *event_pool, int fd, GF_VALIDATE_OR_GOTO ("event", event_pool, out); + /* During shutdown, it may happen that a socket registration with + * the event sub-system may fail and an rpc_transport_unref() may + * be called for such an unregistered socket with idx == -1. This + * may cause the following assert(slot->fd == fd) to fail. + */ + if (idx < 0) + goto out; + slot = event_slot_get (event_pool, idx); assert (slot->fd == fd); -- cgit