-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Adhoc] Fix possible lock issue and Updated PdpStat #14060
Conversation
…rg (since we use larger buffer size to prevent micro stutters or disconnection issue due to too many dropped packets with small buffer size). TODO: May need to improve it to be able to calculate the correct size if there are multiple datagram messages
static int lastUdpBufSize = 0; | ||
static char* buf = NULL; | ||
if (udpBufferSize > lastUdpBufSize) { | ||
// Reusing temp buffer to prevent causing too many fragmentation due to repeated alloc -> free (was getting out of memory issue) |
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.
if you were really running out of memory, you would have been leaking. I don't think fragmentation here would cause such serious issues..
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.
It might not be fragmentation, i only gets out of memory (my monitor goes blank and a popup related to memory appeared) when debugging it through Visual Studio 2019, may be it's VS Debugger bug on memory allocation?
It's just a simple:
char *buf = (char*)malloc(size);
err = recvfrom(...);
free(buf);
So i can't really tell where the leaks came from, and i certainly don't want to get issue while debugging.
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.
That's really odd, something like that shouldn't run of RAM.
However, if realloc fixes it, let's go with that, I guess..
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.
Hmm... i think we don't really need to provide a large buffer since we only need to retrieved the message size, and it seems with MSG_TRUNC
we can provide small buffer and it will still return the actual message size (one full message)
What games have issues that this will fix? Just curious. |
Currently there are no game that have issue with current socket stats, just trying to get the stat data correctly. While the lock/unlock issue is certainly something that need to be fixed (although normally almost never reach that point of code) There is one game i know that relies on the number of byte available to receive and affects the FPS, which is Warriors Orochi 2. My previous solution to prevent the FPS/VPS from dropping too much was by reducing the buffer size, but apparently VPN doesn't worked well with small buffer size (may be due to higher latency it need to be able to buffer more data). |
TODO: May need to improve it to be able to calculate the correct size if there are multiple datagram messages