diff options
author | Mark Nunberg <mnunberg@users.noreply.github.com> | 2018-10-03 06:53:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-03 06:53:42 -0400 |
commit | 67036ef70c9b332c51fe24489fc9f9cdaa09dbe3 (patch) | |
tree | d0c133ad2b3cc92a43045a61ae0dfe956f464add /async.c | |
parent | 747d78beaa66ef1666de7ea0153f2bc2504b8ee5 (diff) | |
parent | 3cb4fb2395919ff91d29c7ab66634f5211eaca89 (diff) |
Merge pull request #578 from mnunberg/connfix
Proper error reporting for connect failures
Diffstat (limited to 'async.c')
-rw-r--r-- | async.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -506,22 +506,22 @@ void redisProcessCallbacks(redisAsyncContext *ac) { * write event fires. When connecting was not successful, the connect callback * is called with a REDIS_ERR status and the context is free'd. */ static int __redisAsyncHandleConnect(redisAsyncContext *ac) { + int completed = 0; redisContext *c = &(ac->c); - - if (redisCheckSocketError(c) == REDIS_ERR) { - /* Try again later when connect(2) is still in progress. */ - if (errno == EINPROGRESS) - return REDIS_OK; - - if (ac->onConnect) ac->onConnect(ac,REDIS_ERR); + if (redisCheckConnectDone(c, &completed) == REDIS_ERR) { + /* Error! */ + redisCheckSocketError(c); + if (ac->onConnect) ac->onConnect(ac, REDIS_ERR); __redisAsyncDisconnect(ac); return REDIS_ERR; + } else if (completed == 1) { + /* connected! */ + if (ac->onConnect) ac->onConnect(ac, REDIS_OK); + c->flags |= REDIS_CONNECTED; + return REDIS_OK; + } else { + return REDIS_OK; } - - /* Mark context as connected. */ - c->flags |= REDIS_CONNECTED; - if (ac->onConnect) ac->onConnect(ac,REDIS_OK); - return REDIS_OK; } /* This function should be called when the socket is readable. |