-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
The setsockopt and getsockopt API diffs from BSD socket and WSA one #662
Conversation
This looks fine to me, though we don't ever use |
But we use setsockopt, which will cause the real timeout divided by 1000 in windows, if we connect redis server with a specified timeout, and usually it will make the connection very unstable when testing the new windows port of hiredis. |
sockcompat.c
Outdated
int ret = setsockopt(sockfd, level, optname, (const char*)optval, optlen); | ||
int ret = 0; | ||
if ((level == SOL_SOCKET) && ((optname == SO_RCVTIMEO) || (optname == SO_SNDTIMEO))) { | ||
struct timeval *tv = (struct timeval *)optval; |
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.
const struct timeval *tv = optval; eliminate casting plz
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.
Did it
Actually, it's used here: https://github.com/redis/hiredis/blob/master/net.c#L294, although only for |
Is this safe to merge? A few people have been having timeout related issues in Windows. |
The optval of
SO_RCVTIMEO
andSO_SNDTIMEO
is a pointer toDWORD
, not a pointer tostruct timeval
in Windows SDK.ref: