proxy forgets packages if debuggee connects#346
proxy forgets packages if debuggee connects#346vvvrrooomm wants to merge 1 commit intoactboy168:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the on_accepted callback in extension/script/common/socket.lua to initialize a session and handle buffered writes. However, the added logic is unreachable due to an early return statement. Additionally, the code contains an undefined variable reference and an inappropriate use of assert that could lead to crashes; a refactored approach was suggested to correctly handle session initialization and buffer flushing.
extension/script/common/socket.lua
Outdated
| local ok = init_session(s) | ||
| assert(ok) | ||
| if writebuf ~= '' then | ||
| s:write(writebuf) | ||
| writebuf = '' | ||
| end |
There was a problem hiding this comment.
The code added here is unreachable because of the return statement on line 88. Additionally, the variable s is undefined in this scope; it should be new_s. Finally, using assert(ok) is problematic here because init_session returns nil if a session already exists (e.g., if another client is already connected), which should result in rejecting the new connection rather than crashing the proxy.
To fix this, remove the return on line 88 and refactor the block as follows:
function server:on_accepted(new_s)
local ok = init_session(new_s)
if ok then
if writebuf ~= '' then
new_s:write(writebuf)
writebuf = ''
end
end
return ok
endthis might fix actboy168#344 when lua-debug wait for a conencting debuggee, after the connection is accepted nothing happens. lua-debug should send queued packages in that case, as it does in the other case where lua-debug connects to the debuggee
7565a9c to
a387134
Compare
this might fix #344
when lua-debug wait for a conencting debuggee, after the connection is accepted nothing happens. lua-debug should send queued packages in that case, as it does in the other case where lua-debug connects to the debuggee