diff options
author | Kristján Valur Jónsson <sweskman@gmail.com> | 2021-03-26 14:40:32 +0000 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2022-06-26 13:19:33 -0700 |
commit | 5e002bc21c6b7483592cd66417bf7a374590b973 (patch) | |
tree | 19e5aa2b10816bbf78e780f0b9cd52695ca2e92d /net.c | |
parent | 5d68ad2f48e908ff7fe2debe22f71182c2150547 (diff) |
Support failed async connects on windows.
Diffstat (limited to 'net.c')
-rw-r--r-- | net.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -277,12 +277,29 @@ int redisCheckConnectDone(redisContext *c, int *completed) { *completed = 1; return REDIS_OK; } - switch (errno) { + int error = errno; + if (error == EINPROGRESS) + { + /* must check error to see if connect failed. Get the socket error */ + int fail, so_error, optlen; + optlen = sizeof(so_error); + fail = getsockopt(c->fd, SOL_SOCKET, SO_ERROR, &so_error, &optlen); + if (fail == 0) { + if (so_error == 0) { + /* ocket is connected! */ + *completed = 1; + return REDIS_OK; + } + /* connection error; */ + errno = so_error; + error = so_error; + } + } + switch (error) { case EISCONN: *completed = 1; return REDIS_OK; case EALREADY: - case EINPROGRESS: case EWOULDBLOCK: *completed = 0; return REDIS_OK; |