Skip to content

Commit

Permalink
issue: Remove free_evh_resources()
Browse files Browse the repository at this point in the history
This method simply calls stop_thread(). Remove it to simply the code and
separate thread stopping from epfd closing.

Signed-off-by: Dmytro Podgornyi <[email protected]>
  • Loading branch information
pasis committed Oct 2, 2024
1 parent 19bdde1 commit 9d5cf55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
29 changes: 8 additions & 21 deletions src/core/event/event_handler_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,38 +264,31 @@ event_handler_manager::event_handler_manager(bool internal_thread_mode)
m_epfd = -1;
m_event_handler_tid = 0;

m_b_continue_running = true;
if (!internal_thread_mode) {
m_b_continue_running = true;
return;
}

m_epfd = SYSCALL(epoll_create, INITIAL_EVENTS_NUM);
BULLSEYE_EXCLUDE_BLOCK_START
if (m_epfd == -1) {
evh_logdbg("epoll_create failed on ibv device collection (errno=%d %m)", errno);
free_evh_resources();
throw_xlio_exception("epoll_create failed on ibv device collection");
}
BULLSEYE_EXCLUDE_BLOCK_END

m_b_continue_running = true;

wakeup_set_epoll_fd(m_epfd);
going_to_sleep();
}

event_handler_manager::~event_handler_manager()
{
free_evh_resources();
}

void event_handler_manager::free_evh_resources()
{
evh_logfunc("");

// Flag thread to stop on next loop
stop_thread();
evh_logfunc("Thread stopped");

if (m_epfd >= 0) {
SYSCALL(close, m_epfd);
}
m_epfd = -1;
}

// event handler main thread startup
Expand Down Expand Up @@ -407,18 +400,12 @@ void event_handler_manager::stop_thread()
// Wait for thread exit
if (m_event_handler_tid) {
pthread_join(m_event_handler_tid, nullptr);
evh_logdbg("event handler thread stopped");
evh_logdbg("Event handler thread stopped.");
} else {
evh_logdbg("event handler thread not running");
evh_logdbg("Event handler thread not running.");
}
}
m_event_handler_tid = 0;

// Close main epfd and signaling socket
if (m_epfd >= 0) {
SYSCALL(close, m_epfd);
}
m_epfd = -1;
}

void event_handler_manager::update_epfd(int fd, int operation, int events)
Expand Down
2 changes: 0 additions & 2 deletions src/core/event/event_handler_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ class event_handler_manager : public wakeup_pipe {

void event_channel_post_process_for_rdma_events(void *p_event);
void *event_channel_pre_process_for_rdma_events(void *p_event_channel_handle, void **p_event);

void free_evh_resources(void);
};

extern event_handler_manager *g_p_event_handler_manager;
Expand Down

0 comments on commit 9d5cf55

Please sign in to comment.