proxy forgets packages if debuggee connects - #346
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.
| 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:
functionserver:on_accepted(new_s)
localok=init_session(new_s)
ifokthenifwritebuf~='' thennew_s:write(writebuf)
writebuf=''endendreturnokendthis might fixactboy168#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
a387134CompareUh oh!
There was an error while loading. Please reload this page.
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