Skip to content
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

Maybe incorrect redisContextSetTimeout implement for windows. #695

Closed
heroboy opened this issue Aug 1, 2019 · 1 comment
Closed

Maybe incorrect redisContextSetTimeout implement for windows. #695

heroboy opened this issue Aug 1, 2019 · 1 comment

Comments

@heroboy
Copy link

heroboy commented Aug 1, 2019

int redisContextSetTimeout(redisContext *c, const struct timeval tv) {
    if (setsockopt(c->fd,SOL_SOCKET,SO_RCVTIMEO,&tv,sizeof(tv)) == -1) {
        __redisSetErrorFromErrno(c,REDIS_ERR_IO,"setsockopt(SO_RCVTIMEO)");
        return REDIS_ERR;
    }
    if (setsockopt(c->fd,SOL_SOCKET,SO_SNDTIMEO,&tv,sizeof(tv)) == -1) {
        __redisSetErrorFromErrno(c,REDIS_ERR_IO,"setsockopt(SO_SNDTIMEO)");
        return REDIS_ERR;
    }
    return REDIS_OK;
}

https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt

On windows,the argument of SO_RCVTIMEO shoud be a DWORD in milliseconds. And timeval is a two long variable struct. The first long is sec. So when you want set 1 second timeout,then it will be 1ms.

@heroboy heroboy changed the title Maybe incorrect redisContextSetTimeout implement for window. Maybe incorrect redisContextSetTimeout implement for windows. Aug 1, 2019
@michael-grunder
Copy link
Collaborator

michael-grunder commented Aug 1, 2019

Hi @heroboy,

This is indeed a bug. There are two open PRs that address it currently:

#662
#670

I can't be of much more help since I don't have a Windows machine and am not sure if there are plans to merge them any time soon.

@mnunberg mnunberg closed this as completed Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants