diff options
| author | Nils Maier <maierman@web.de> | 2013-04-10 21:54:34 +0200 |
|---|---|---|
| committer | Nils Maier <maierman@web.de> | 2013-04-17 15:53:06 +0200 |
| commit | 1cd5dcc9b692ef9c32bcd5aaada54a9c80636595 (patch) | |
| tree | 3c000d69469117c7963e063a203f4de4eaee1bc4 /src/LibuvEventPoll.h | |
| parent | 9acd3df3cb833e429687347a0d049306353c6e2a (diff) | |
LibUV: Correct event removal
Diffstat (limited to 'src/LibuvEventPoll.h')
| -rw-r--r-- | src/LibuvEventPoll.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/LibuvEventPoll.h b/src/LibuvEventPoll.h index 54ced26b..330f1b60 100644 --- a/src/LibuvEventPoll.h +++ b/src/LibuvEventPoll.h @@ -71,13 +71,20 @@ private: friend int accumulateEvent(int events, const KEvent& event); private: - uv_loop_t* loop; + uv_loop_t* loop_; typedef std::set<SharedHandle<KSocketEntry>, DerefLess<SharedHandle<KSocketEntry> > > KSocketEntrySet; KSocketEntrySet socketEntries_; - typedef std::map<sock_t, uv_poll_t*> KPolls; + typedef struct { + uv_poll_t p; + KSocketEntry *entry; + LibuvEventPoll *eventer; + int events; + } poll_t; + + typedef std::map<sock_t, poll_t*> KPolls; KPolls polls_; #ifdef ENABLE_ASYNC_DNS @@ -98,14 +105,21 @@ private: #endif static int translateEvents(EventPoll::EventType events); - static void poll_callback(uv_poll_t* handle, int status, int events); + static void close_poll_callback(uv_handle_t* handle) { + delete static_cast<poll_t*>(handle->data); + } + static void poll_callback(uv_poll_t* handle, int status, int events) { + poll_t* poll = static_cast<poll_t*>(handle->data); + poll->eventer->pollCallback(handle, poll, status, events); + } + void pollCallback(uv_poll_t* handle, poll_t *poll, int status, int events); public: LibuvEventPoll(); virtual ~LibuvEventPoll(); - bool good() const { return loop; } + bool good() const { return loop_; } virtual void poll(const struct timeval& tv); |
