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
Move SocketManager's DecodeError to Common #11003
Conversation
fab9314
to
a333074
Compare
Fix thread safety issue
|
I think you're probably better off just returning an |
I'm forced to use a thread_local/static buffer on Windows to retrieve WinSock errors using |
|
Wait, why are you forced into a static buffer on Windows? What's stopping you from just doing |
Won't this have a negative impact on performance by creating the buffer each time there is an error, on top of copying it into a |
|
The buffer itself is on the stack, so that's free. The conversion to std::string does indeed cost a copy to the heap, but I kinda doubt it's worth caring about. I guess it depends on how likely you think it is that someone calls If you want both perf and safety, at the cost of slightly less convenience, you can let the user of |
Most of its uses are for error logs so changing the prototype to take a buffer would defeat its purpose. It's used a bit like |
|
@AdmiralCurtiss I don't know how precise the FPS counter is but that seems to be a significant performance loss. If you know a better way to measure this, I'm open to suggestions as well. |
|
Doesn't make me happy, but yeah, that's significant. |
This PR moves the socket manager decode error function to Common and should fix a thread safety issue. I plan to use this method on other places not related to Wii sockets such as BBA HLE.
Ready to be reviewed & merged.
EDIT: I didn't know that using
strerror_rwould be that difficult. I don't know if we (or the compiler) did/do/will enable GNU extension. Here are some references/differences depending on the system: