Merge pull request #2545 from mmastrac/master

Fix for issue 1968: use uv_backend_timeout to determine timeout to match other platforms
This commit is contained in:
Cheng Zhao 2015-08-21 11:33:43 +08:00
commit b4da15bba8

View file

@ -22,24 +22,14 @@ NodeBindingsWin::~NodeBindingsWin() {
} }
void NodeBindingsWin::PollEvents() { void NodeBindingsWin::PollEvents() {
// Unlike Unix, in which we can just rely on one backend fd to determine // If there are other kinds of events pending, uv_backend_timeout will
// whether we should iterate libuv loop, on Window, IOCP is just one part // instruct us not to wait.
// of the libuv loop, we should also check whether we have other types of
// events.
bool block = uv_loop_->idle_handles == NULL &&
uv_loop_->pending_reqs_tail == NULL &&
uv_loop_->endgame_handles == NULL &&
!uv_loop_->stop_flag &&
(uv_loop_->active_handles > 0 ||
!QUEUE_EMPTY(&uv_loop_->active_reqs));
// When there is no other types of events, we block on the IOCP.
if (block) {
DWORD bytes, timeout; DWORD bytes, timeout;
ULONG_PTR key; ULONG_PTR key;
OVERLAPPED* overlapped; OVERLAPPED* overlapped;
timeout = uv_backend_timeout(uv_loop_); timeout = uv_backend_timeout(uv_loop_);
GetQueuedCompletionStatus(uv_loop_->iocp, GetQueuedCompletionStatus(uv_loop_->iocp,
&bytes, &bytes,
&key, &key,
@ -53,7 +43,6 @@ void NodeBindingsWin::PollEvents() {
key, key,
overlapped); overlapped);
} }
}
// static // static
NodeBindings* NodeBindings::Create(bool is_browser) { NodeBindings* NodeBindings::Create(bool is_browser) {