File tree Expand file tree Collapse file tree 5 files changed +25
-4
lines changed
Expand file tree Collapse file tree 5 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -3,20 +3,26 @@ local channel = require "bee.channel"
33
44local m = {}
55
6+ -- Stores the name of the master channel
7+ --- @type string | nil
8+ DbgMaster = DbgMaster
9+
610local function hasMaster ()
7- return channel .query " DbgMaster" ~= nil
11+ return DbgMaster and channel .query ( DbgMaster ) ~= nil
812end
913
1014local function initMaster (rootpath , address )
1115 if hasMaster () then
1216 return
1317 end
14- local chan = channel .create " DbgMaster"
18+ DbgMaster = " DbgMaster-" .. address
19+ local chan = channel .create (DbgMaster )
1520 local mt = thread .create (([[
1621 local rootpath = %q
1722 package.path = rootpath.."/script/?.lua"
1823 local log = require "common.log"
1924 log.file = rootpath.."/master.log"
25+ DbgMaster = %q
2026 local ok, err = xpcall(function()
2127 local socket = require "common.socket"(%q)
2228 local master = require "backend.master.mgr"
@@ -28,11 +34,15 @@ local function initMaster(rootpath, address)
2834 end
2935 ]] ):format (
3036 rootpath ,
37+ DbgMaster ,
3138 address
3239 ))
3340 ExitGuard = setmetatable ({}, {__gc = function ()
3441 chan :push (nil , " EXIT" )
3542 thread .wait (mt )
43+ local WorkerIdent = tostring (thread .id )
44+ local WorkerChannel = (' DbgWorker(%s)' ):format (WorkerIdent )
45+ channel .destroy (WorkerChannel )
3646 end })
3747end
3848
Original file line number Diff line number Diff line change 4343
4444function mgr .init (io )
4545 socket = io
46- masterThread = assert (channel .query ' DbgMaster' )
46+ masterThread = assert (channel .query ( DbgMaster ) )
4747 socket .event_close (event_close )
4848 return true
4949end
@@ -260,6 +260,7 @@ function mgr.update()
260260 local event = require ' backend.master.event'
261261 event .terminated ()
262262 socket .closeall ()
263+ channel .destroy (DbgMaster )
263264end
264265
265266function mgr .setClient (c )
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ local CMD = {}
3636local WorkerIdent = tostring (thread .id )
3737local WorkerChannel = (' DbgWorker(%s)' ):format (WorkerIdent )
3838
39- local masterThread = assert (channel .query ' DbgMaster' )
39+ local masterThread = assert (channel .query ( DbgMaster ) )
4040local workerThread = channel .create (WorkerChannel )
4141
4242local function workerThreadUpdate (timeout )
Original file line number Diff line number Diff line change @@ -199,6 +199,10 @@ function dbg:attach(cfg)
199199 return self
200200end
201201
202+ function dbg :stop ()
203+ self .rdebug .clear ()
204+ end
205+
202206function dbg :event (...)
203207 self .rdebug .event (... )
204208 return self
Original file line number Diff line number Diff line change @@ -568,6 +568,10 @@ struct hookmgr {
568568 }
569569 luadebug::eventfree::destroy (hL, eventfree);
570570 lua_sethook (hL, 0 , 0 , 0 );
571+ #if defined(LUADEBUG_DISABLE_THUNK)
572+ // clear hook manager pointer stored in thunk:
573+ thunk_set (hL, &THUNK_MGR, (intptr_t )nullptr );
574+ #endif
571575#if defined(LUA_HOOKEXCEPTION)
572576 exception_open (hL, 0 );
573577#endif
@@ -594,11 +598,13 @@ struct hookmgr {
594598#else
595599 static int full_hook_callback (lua_State* hL, lua_Debug* ar) {
596600 hookmgr* mgr = (hookmgr*)thunk_get (hL, &THUNK_MGR);
601+ if (!mgr) return 0 ;
597602 mgr->full_hook (hL, ar);
598603 return 0 ;
599604 }
600605 static int idle_hook_callback (lua_State* hL, lua_Debug* ar) {
601606 hookmgr* mgr = (hookmgr*)thunk_get (hL, &THUNK_MGR);
607+ if (!mgr) return 0 ;
602608 mgr->idle_hook (hL, ar);
603609 return 0 ;
604610 }
You can’t perform that action at this time.
0 commit comments