minecraft/conn.go: Re-check deferred packets on expect() to prevent handshake deadlock#406
minecraft/conn.go: Re-check deferred packets on expect() to prevent handshake deadlock#406iteplenky wants to merge 1 commit intoSandertv:masterfrom
Conversation
| return | ||
| } | ||
| deferred := conn.deferredPackets | ||
| conn.deferredPackets = nil |
There was a problem hiding this comment.
I would change this to be conn.deferredPackets = conn.deferredPackets[len(deferred):] just to keep the pre-allocated size
|
you can just add resourcepacks info to this list gophertunnel/minecraft/dial.go Line 298 in 9c440d5 |
I guess it depends how far the client lets you go with the ordering of these packets. The PR's implementation is the most future-proof way, but if the fix you've provided is solid enough then maybe it's better to merge that over this |
|
been using it for over a year |
|
My point isn't for what works currently, it's what is best going forward so we don't need to make yet another change when a server sends a packet in a slightly different order that isn't caught by the current code |
|
ik i agree |
If a packet arrives before expect() adds its ID to the expected set, it gets deferred and never re-checked — causing the handshake to hang indefinitely. Fix: after storing new expected IDs, pass all deferred packets back through handle(). Matching packets are processed immediately; the rest are re-deferred automatically.
1ae7b9c to
195bfab
Compare
|
@HashimTheArab Re: adding The |
When a server sends
ResourcePacksInfobeforePlayStatus(LoginSuccess),the packet gets deferred because its ID isn't in
expectedIDsyet. WhenPlayStatuslater arrives andexpect(IDResourcePacksInfo)is called,the already-deferred packet is never re-checked — causing
Dial()todeadlock waiting for a packet that's already been received and discarded.
This adds
handleDeferredPackets()which is called fromexpect()tore-process deferred packets against the updated expected set. Packets
that still don't match are re-deferred by
handle()automatically.Observed on: Hive, Lifeboat, Galaxite (intermittent, depends on packet
arrival order which varies per connection).