-
-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix race condition when handling plugins packets #1673
base: main
Are you sure you want to change the base?
Fix race condition when handling plugins packets #1673
Conversation
There's a race condition in the access of the packets CircularBuffers, between the render thread, which reads the packets from the Server->Client buffer, the Plugin->Client buffer and the Plugins thread which can enqueue new packets to be read by the Client. Add a lock when appending data to each of the receiving buffers. Remove the lock to the packet handler when the plugin appends new packets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it should add stability to packet reads. Helping to alleviate incorrect offsetting of packet data.
I built with this last night and still experienced the issue after a couple hours. I got the endless page flipping book and frozen character. I've been using this script to recreate. still takes a few hours sometimes.
|
I think the issue you are experiencing here might be related to: #1674 There may be some other bug actually unrelated to this that it's now surfaced due to the fix. But without this fix I was almost unable to use scripts, due to crashes, and so on. |
You may be right but I think the condition occurs when compressed packets are sent from the server and irritates the race condition. I'll reply to #1674 with some packet logs snips showing why I feel that way. I was getting the issue both before and after using your pull req. the playerupdate packet ID: 78 is one of the compressed packets as well as ID: AE. both are in my packetdumps from CUO but don't show up in a wireshark trace because they are compressed which shifts the byte data. I think it is the decompression of these packets that is creating the issue you and I are experiencing. It only occurs when a plugin is active in my experience though admittedly it's very difficult to test without macros. I'll stop derailing this thread and add to 1674 |
There's a race condition in the access of the packets CircularBuffers, between the render thread, which reads the packets from the Server->Client buffer, the Plugin->Client buffer and the Plugins thread which can enqueue new packets to be read by the Client.
Add a lock when appending data to each of the receiving buffers. Remove the lock to the packet handler when the plugin appends new packets.
Fixes #1665
Fixes #1618
This is the second attempt, more info also at #1670