projects
/
invirt/third/libt4.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
So many changes. Broken.
[invirt/third/libt4.git]
/
rpc
/
poll_mgr.cc
diff --git
a/rpc/poll_mgr.cc
b/rpc/poll_mgr.cc
index
2598249
..
a3ab08a
100644
(file)
--- a/
rpc/poll_mgr.cc
+++ b/
rpc/poll_mgr.cc
@@
-1,15
+1,16
@@
-#include "poll_mgr.h"
+#include "include/rpc/poll_mgr.h"
#include <errno.h>
#include <sys/select.h>
#include <errno.h>
#include <sys/select.h>
-#include "file.h"
+#include "include/rpc/file.h"
+#include "include/debug.h"
#ifdef __linux__
#include <sys/epoll.h>
#endif
#ifdef __linux__
#include <sys/epoll.h>
#endif
-aio_callback::~aio_callback() {}
+using std::vector;
-poll_mgr poll_mgr::shared_mgr;
+aio_callback::~aio_callback() {}
class wait_manager {
public:
class wait_manager {
public:
@@
-33,7
+34,7
@@
class SelectAIO : public wait_manager {
fd_set rfds_, wfds_;
int highfds_;
file_t pipe_[2];
fd_set rfds_, wfds_;
int highfds_;
file_t pipe_[2];
- mutex m_;
+ std::mutex m_;
};
#ifdef __linux__
};
#ifdef __linux__
@@
-57,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;
@@
-69,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);
@@
-196,7
+200,7
@@
void SelectAIO::wait_ready(vector<int> & readable, vector<int> & writable) {
return;
else if (ret < 0) {
perror("select:");
return;
else if (ret < 0) {
perror("select:");
- IF_LEVEL(0) LOG("select_loop failure errno " << errno);
+ IF_LEVEL(0) LOG << "select_loop failure errno " << errno;
VERIFY(0);
}
VERIFY(0);
}