mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-22 09:30:45 +00:00
core: exit program by breaking the loop rather than exit()
This gives more destructors the option to run, making an easier job for leak detectors.
This commit is contained in:
@@ -44,7 +44,7 @@ reactor::reactor()
|
||||
_io_eventfd.wait().then([this] (size_t count) {
|
||||
process_io(count);
|
||||
});
|
||||
receive_signal(SIGINT).then([] { ::exit(255); });
|
||||
receive_signal(SIGINT).then([this] { _stopped = true; });
|
||||
}
|
||||
|
||||
future<> reactor::get_epoll_future(pollable_fd_state& pfd,
|
||||
@@ -266,6 +266,9 @@ void reactor::run() {
|
||||
current_tasks.clear();
|
||||
}
|
||||
std::array<epoll_event, 128> eevt;
|
||||
if (_stopped) {
|
||||
break;
|
||||
}
|
||||
int nr = ::epoll_wait(_epollfd.get(), eevt.data(), eevt.size(), -1);
|
||||
if (nr == -1 && errno == EINTR) {
|
||||
continue; // gdb can cause this
|
||||
|
||||
@@ -296,6 +296,7 @@ class reactor {
|
||||
signalfd_siginfo _siginfo;
|
||||
};
|
||||
std::unordered_map<int, signal_handler> _signal_handlers;
|
||||
bool _stopped = false;
|
||||
public:
|
||||
file_desc _epollfd;
|
||||
readable_eventfd _io_eventfd;
|
||||
|
||||
Reference in New Issue
Block a user