This discussion is related to the test failing in bug 21271: http://bugs.winehq.org/show_bug.cgi?id=21271
The SIO_KEEPALIVE_VALS message on windows takes parameters as miliseconds, on some other systems there are the equivalent TCP_KEEPIDLE/TCP_KEEPINTVL which takes the parameters as seconds. To solve this there is a division by 1000 on wine source code but the problem is that values < 1000 become 0 making the setsockopt function return error.
Is it reasonable to do a check to see if the result of the division is zero and then set the variable to one so we can get closer to the windows implementation and not fail the setsockopt function? It will obviously not match 100% the windows implementation but it seems to be as close as we can get and as far as I can think it's better for the applications to receive a one second keepalive then never receiving any.
SIO_KEEPALIVE_VALS bibliography (read specially the remarks): http://msdn.microsoft.com/en-us/library/dd877220%28v=vs.85%29.aspx
TCP_KEEPIDLE/TCP_KEEPINTVL bibliography (almost no information, sorry) http://linux.die.net/man/7/tcp http://www.yolinux.com/TUTORIALS/Sockets.html
Wine source code link (ignore the fact that there may be a read on address zero that is only checked later): http://source.winehq.org/source/dlls/ws2_32/socket.c#L3362
I have tested locally and will try to add tests to wine git but I prefered to start the discussion first. If I have missed something or this was already discussed accept my apologies in advance.
Best wishes, Bruno
Hi Bruno,
The SIO_KEEPALIVE_VALS message on windows takes parameters as miliseconds, on some other systems there are the equivalent TCP_KEEPIDLE/TCP_KEEPINTVL which takes the parameters as seconds. To solve this there is a division by 1000 on wine source code but the problem is that values < 1000 become 0 making the setsockopt function return error.
Is it reasonable to do a check to see if the result of the division is zero and then set the variable to one so we can get closer to the windows implementation and not fail the setsockopt function? It will
Yes, it's reasonable. I think API-level compatibility is generally more important to appilcations than timing-level compatibility. I.o.w. function(args) -> result should be invariant across Windows and Wine. The time required to before function(args) yields result is oftentimes not guaranteed in Windows, so a little fuzziness here is often okay. --Juan