Software /
code /
prosody
Comparison
util-src/poll.c @ 13329:649876680bf0
util.poll: Return early if given zero timeout and no pending events
Should have been part of f33887f925e1 to ensure it won't skip processing
timers at all when very busy.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 21 Nov 2023 17:43:46 +0100 |
parent | 12976:a187600ec7d6 |
child | 13335:8b3bf0d2ffd4 |
comparison
equal
deleted
inserted
replaced
13328:36284c879e2f | 13329:649876680bf0 |
---|---|
409 } | 409 } |
410 | 410 |
411 lua_Number timeout = luaL_checknumber(L, 2); | 411 lua_Number timeout = luaL_checknumber(L, 2); |
412 luaL_argcheck(L, timeout >= 0, 1, "positive number expected"); | 412 luaL_argcheck(L, timeout >= 0, 1, "positive number expected"); |
413 | 413 |
414 if(timeout == 0.0) { | |
415 lua_pushnil(L); | |
416 lua_pushstring(L, "timeout"); | |
417 return 2; | |
418 } | |
419 | |
414 #ifdef USE_EPOLL | 420 #ifdef USE_EPOLL |
415 ret = epoll_wait(state->epoll_fd, state->events, MAX_EVENTS, timeout * 1000); | 421 ret = epoll_wait(state->epoll_fd, state->events, MAX_EVENTS, timeout * 1000); |
416 #endif | 422 #endif |
417 #ifdef USE_POLL | 423 #ifdef USE_POLL |
418 ret = poll(state->events, state->count, timeout * 1000); | 424 ret = poll(state->events, state->count, timeout * 1000); |