projects
/
invirt/third/libt4.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clean-ups
[invirt/third/libt4.git]
/
rpc
/
poll_mgr.cc
diff --git
a/rpc/poll_mgr.cc
b/rpc/poll_mgr.cc
index
83289a8
..
102b8dc
100644
(file)
--- a/
rpc/poll_mgr.cc
+++ b/
rpc/poll_mgr.cc
@@
-2,6
+2,7
@@
#include <errno.h>
#include <sys/select.h>
#include "file.h"
#include <errno.h>
#include <sys/select.h>
#include "file.h"
+#include "threaded_log.h"
#ifdef __linux__
#include <sys/epoll.h>
#ifdef __linux__
#include <sys/epoll.h>
@@
-11,8
+12,6
@@
using std::vector;
aio_callback::~aio_callback() {}
aio_callback::~aio_callback() {}
-poll_mgr poll_mgr::shared_mgr;
-
class wait_manager {
public:
virtual void watch_fd(int fd, poll_flag flag) = 0;
class wait_manager {
public:
virtual void watch_fd(int fd, poll_flag flag) = 0;
@@
-59,9
+58,14
@@
poll_mgr::poll_mgr() : aio_(new SelectAIO()) {
th_ = thread(&poll_mgr::wait_loop, this);
}
th_ = thread(&poll_mgr::wait_loop, this);
}
-poll_mgr::~poll_mgr()
-{
+poll_mgr::~poll_mgr() {
+ shutdown();
+}
+
+void poll_mgr::shutdown() {
lock ml(m_);
lock ml(m_);
+ if (shutdown_)
+ return;
for (auto p : callbacks_)
aio_->unwatch_fd(p.first, CB_RDWR);
pending_change_ = true;
for (auto p : callbacks_)
aio_->unwatch_fd(p.first, CB_RDWR);
pending_change_ = true;
@@
-71,9
+75,7
@@
poll_mgr::~poll_mgr()
th_.join();
}
th_.join();
}
-void
-poll_mgr::add_callback(int fd, poll_flag flag, aio_callback *ch)
-{
+void poll_mgr::add_callback(int fd, poll_flag flag, aio_callback *ch) {
lock ml(m_);
aio_->watch_fd(fd, flag);
lock ml(m_);
aio_->watch_fd(fd, flag);