# HG changeset patch # User Matthew Wild # Date 1235709336 0 # Node ID 1d2dab41b0db78384f1445e7aafcb91d48302e2f # Parent 4932f94d35c1b99013bbe62b6381972162e50c10 prosody: Protect main loop. Dare I say crashing finally becomes impossible. diff -r 4932f94d35c1 -r 1d2dab41b0db prosody --- a/prosody Thu Feb 26 22:17:55 2009 +0000 +++ b/prosody Fri Feb 27 04:35:36 2009 +0000 @@ -7,14 +7,14 @@ -- COPYING file in the source package for more information. -- --- Config here -- +-- Will be modified by configure script if run -- CFG_SOURCEDIR=nil; CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR"); CFG_PLUGINDIR=nil; CFG_DATADIR=os.getenv("PROSODY_DATADIR"); --- -- -- -- -- -- +-- -- -- -- -- -- -- ---- -- -- -- -- -- -- -- -- if CFG_SOURCEDIR then package.path = CFG_SOURCEDIR.."/?.lua;"..package.path @@ -84,7 +84,9 @@ require "core.sessionmanager" require "core.stanza_router" ---[[ +-- Commented to protect us from +-- the second kind of people +--[[ pcall(require, "remdebug.engine"); if remdebug then remdebug.engine.start() end ]] @@ -104,6 +106,7 @@ ----------- End of out-of-place code -------------- + eventmanager.fire_event("server-starting"); @@ -148,4 +151,13 @@ eventmanager.fire_event("server-started"); -server.loop(); +local quitting; +while not quitting do + xpcall(server.loop, function (err) + if err:match("%d*: interrupted!$") then + quitting = true; + return; + end + eventmanager.fire_event("very-bad-error", "*", err, debug.traceback("", 2)); + end); +end