summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-12-14 00:43:38 +0800
committerruki <[email protected]>2019-12-13 22:21:53 +0800
commit4f171e9e2b1eb119b43f08db23c9e6f271f9021d (patch)
treee1e142910d252e7cab1702265295660a43d80c1c
parentbabb970d8ce06e0d93ea9688cfe03e9e3e117804 (diff)
fix event cache for scheduler
-rw-r--r--xmake/core/base/scheduler.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua
index 1e0875105..677b50409 100644
--- a/xmake/core/base/scheduler.lua
+++ b/xmake/core/base/scheduler.lua
@@ -202,7 +202,7 @@ function scheduler:waitsock(sock, events, timeout)
local events_prev_save = bit.rshift(events_prev, 16)
-- return the cached events directly if the waiting events exists cache
- if events_prev_save ~= 0 and bit.band(events_prev, events) ~= 0 then
+ if events_prev_save ~= 0 and bit.band(events_prev_wait, events) ~= 0 then
-- check error?
if bit.band(events_prev_save, poller.EV_SOCK_ERROR) ~= 0 then
@@ -218,9 +218,9 @@ function scheduler:waitsock(sock, events, timeout)
end
-- modify socket from poller for waiting events if the waiting events has been changed
- if events_prev_save ~= events then
+ if events_prev_wait ~= events then
-- modify socket events
- local ok, errors = poller:insert(poller.OT_SOCK, sock, events, sockevents_cb)
+ local ok, errors = poller:modify(poller.OT_SOCK, sock, events, sockevents_cb)
if not ok then
return -1, errors
end
@@ -241,6 +241,9 @@ function scheduler:waitsock(sock, events, timeout)
end, timeout)
end
+ -- save waiting events
+ self:_sockevents_set(sock:csock(), events)
+
-- wait
return self:co_suspend()
end