http://bugs.winehq.org/show_bug.cgi?id=31438
--- Comment #114 from Heiko lil_tux@web.de --- (In reply to Bruno Jesus from comment #112)
There has been some discussion on wine-devel list about a patch that make Guild Wars 2 work better (lower network latency and less login failures), maybe it's worth a try here. If anyone is interested:
It probably wouldn't help. There's no data around there, yet. Origin/qt does a sendto() and immediately a following recv(), which on nonblocking socket shall return 10035 (WOULDBLOCK) which it does, though the app still tries again directly (or +time(stamp) didn't print useful times) until it somewhen starts to work... just to fail again after some time.
I did several tries to debug that crappy origin problem. What I'm pretty certain of, is that wine seems to send too many messages to those requested with WSAAsyncSelect (in origin's case WM_USER). Which seem to confuse the app and thus the connection/socket is pulled down and a new one initiated.
That's probably the reason why the download is so slow and error prone and also the reason for the network bursting on the host. I.e. Origin stays constantly at 50kb/s (and lowering over time), whilst my system spikes up to 1mb/s, just to drop down to almost 1kb/s and back up to short 1mb/s and back down. I guess that's where the tcp-handshake is done on a new port, due to the old connection being terminated.
So to me it looks like wine sends a message for each incoming packet on the socket, though msdn says it should only send one and wait for re-arming by the application through: "The WS2_32.DLL will not continually flood an application with messages for a particular network event. Having successfully posted notification of a particular event to an application window, no further message(s) for that network event will be posted to the application window until the application makes the function call that implicitly reenables notification of that network event." [1]
Unfortunately, I got lost in debugging the vast amount of messages, sockets, packets and wineserver actions :/ Plus, the Qt5-version of Origin uses Qt 5.1.1, which doesn't have some fixes related to pipe handling (QTBUG-35357, yes, origin uses a pipe named OriginClientService) and (QTBUG-30478). Too bad I couldn't drop in the Qt-5.2-dlls.
Anyway, I tried to make wineserver only post a message once in sock_wake_up() like so: + // If we just posted the specific event, hold next post until re-enablement. + sock->hmask |= (1 << event); + sock->pmask &= ~(1 << event); Unfortunately, that didn't turn out to work (because I don't exactly know how those hold masks work). Re-enabling of events seems to be done in ws2_32 already, though not on the error path (which msdn says should trigger re-enabling also).
And if that network garbage wouldn't be enough, origin after some time requests data from receive with 1 wsabuf of size 1. I don't frikkinly know why, but it seems to be the reason for the cpu-hoggin I see with the new Origin.
So, I'm kinda lost now, too :/
P.S. In my previous hack one could probably guard the usleep in WSAAsyncSelect with an "if (!lEvent)"
[1] http://msdn.microsoft.com/en-us/library/windows/desktop/ms741540%28v=vs.85%2...