aboutsummaryrefslogtreecommitdiffstats
path: root/net/server.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-04-12 02:54:45 +0100
committerMatthew Wild <mwild1@gmail.com>2009-04-12 02:54:45 +0100
commit25de4549ed9b374fbdd9f885b3dc90dee955331d (patch)
tree83a40d772a3b436ac6dd04f0509f0ff15f22ad6f /net/server.lua
parent9008dd1e1cc05ce70366054e370a50a9834bccdd (diff)
downloadprosody-25de4549ed9b374fbdd9f885b3dc90dee955331d.tar.gz
prosody-25de4549ed9b374fbdd9f885b3dc90dee955331d.zip
net.server: Add server.setquitting() to gracefully quit the socket loop
Diffstat (limited to 'net/server.lua')
-rw-r--r--net/server.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/net/server.lua b/net/server.lua
index 755b369e..d151e61d 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -724,8 +724,16 @@ stats = function( )
return _readtraffic, _sendtraffic, _readlistlen, _sendlistlen, _timerlistlen
end
+local dontstop = true;
+
+setquitting = function (quit)
+ dontstop = not quit;
+ return;
+end
+
loop = function( ) -- this is the main loop of the program
- while true do
+ while dontstop do
+ out_put(tostring(dontstop))
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 ]
@@ -760,6 +768,7 @@ loop = function( ) -- this is the main loop of the program
socket_sleep( _sleeptime ) -- wait some time
--collectgarbage( )
end
+ return "quitting"
end
--// EXPERIMENTAL //--
@@ -833,7 +842,7 @@ return {
addtimer = addtimer,
addserver = addserver,
getsettings = getsettings,
+ setquitting = setquitting,
removeserver = removeserver,
changesettings = changesettings,
-
}