aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_select.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-09-09 20:10:28 +0100
committerMatthew Wild <mwild1@gmail.com>2010-09-09 20:10:28 +0100
commit40fa07ecfcaadba2d256b3e092cba17fcb478f7c (patch)
tree00f54b07ea1d35a08bccdd18744a82563912dddd /net/server_select.lua
parent29d0db3fd77e2b8a4857d638ebc5b2fbc8ab6b61 (diff)
downloadprosody-40fa07ecfcaadba2d256b3e092cba17fcb478f7c.tar.gz
prosody-40fa07ecfcaadba2d256b3e092cba17fcb478f7c.zip
net.server_select: Add server.step() to run through a single iteration of the event loop
Diffstat (limited to 'net/server_select.lua')
-rw-r--r--net/server_select.lua18
1 files changed, 12 insertions, 6 deletions
diff --git a/net/server_select.lua b/net/server_select.lua
index a46551b7..c6e90d55 100644
--- a/net/server_select.lua
+++ b/net/server_select.lua
@@ -787,15 +787,16 @@ stats = function( )
return _readtraffic, _sendtraffic, _readlistlen, _sendlistlen, _timerlistlen
end
-local dontstop = true; -- thinking about tomorrow, ...
+local quitting;
setquitting = function (quit)
- dontstop = not quit;
- return;
+ quitting = not not quit;
end
-loop = function( ) -- this is the main loop of the program
- while dontstop do
+loop = function(once) -- this is the main loop of the program
+ if quitting then return "quitting"; end
+ if once then quitting = "once"; end
+ repeat
local read, write, err = socket_select( _readlist, _sendlist, _selecttimeout )
for i, socket in ipairs( write ) do -- send data waiting in writequeues
local handler = _socketlist[ socket ]
@@ -829,10 +830,15 @@ loop = function( ) -- this is the main loop of the program
end
socket_sleep( _sleeptime ) -- wait some time
--collectgarbage( )
- end
+ until quitting;
+ if once and quitting == "once" then quitting = nil; return; end
return "quitting"
end
+step = function ()
+ return loop(true);
+end
+
local function get_backend()
return "select";
end