summaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorMichael Grunder <michael.grunder@gmail.com>2020-04-02 22:41:34 -0700
committerGitHub <noreply@github.com>2020-04-02 22:41:34 -0700
commitcc9d03297177eb8504c7353db673b9dc6f64ea07 (patch)
treeae3711309b9f25b40611f125b029314bff1c7b70 /net.c
parentec18d790f165da1b2e7528828518a3034aa74b9c (diff)
Win32 tests and timeout fix (#776)
Unit tests in Windows and a Windows timeout fix This commit gets our unit tests compiling and running on Windows as well as removes a duplicated `timeval` -> `DWORD` conversion logic in sockcompat.c There are minor differences in behavior between Linux and Windows to note: 1. In Windows, opening a non-existent hangs forever in WSAPoll whereas it correctly returns with a "Connection refused" error on Linux. For that reason, I simply skip this test in Windows. It may be related to this known issue: https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/ 2. Timeouts are handled slightly differently in Windows and Linux. In Linux, we intentionally set REDIS_ERR_IO for connection timeouts whereas in Windows we set REDIS_ERR_TIMEOUT. It may be prudent to fix this discrepancy although there are almost certainly users relying on the current behavior.
Diffstat (limited to 'net.c')
-rw-r--r--net.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/net.c b/net.c
index c928b33..bdb8943 100644
--- a/net.c
+++ b/net.c
@@ -316,11 +316,7 @@ int redisCheckSocketError(redisContext *c) {
int redisContextSetTimeout(redisContext *c, const struct timeval tv) {
const void *to_ptr = &tv;
size_t to_sz = sizeof(tv);
-#ifdef _WIN32
- DWORD timeout_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000;
- to_ptr = &timeout_msec;
- to_sz = sizeof(timeout_msec);
-#endif
+
if (setsockopt(c->fd,SOL_SOCKET,SO_RCVTIMEO,to_ptr,to_sz) == -1) {
__redisSetErrorFromErrno(c,REDIS_ERR_IO,"setsockopt(SO_RCVTIMEO)");
return REDIS_ERR;