Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
cbe4ae63
"app/modules/enduser_setup/enduser_setup_apple.html" did not exist on "04ce0adf6fa7ccda242f1235b7916252cd1ad543"
Commit
cbe4ae63
authored
Mar 05, 2018
by
Mark Nunberg
Browse files
Handle connection errors better in blocking mode as well
parent
5e6bbf8c
Changes
3
Show whitespace changes
Inline
Side-by-side
async.c
View file @
cbe4ae63
...
@@ -508,7 +508,7 @@ void redisProcessCallbacks(redisAsyncContext *ac) {
...
@@ -508,7 +508,7 @@ void redisProcessCallbacks(redisAsyncContext *ac) {
static
int
__redisAsyncHandleConnect
(
redisAsyncContext
*
ac
)
{
static
int
__redisAsyncHandleConnect
(
redisAsyncContext
*
ac
)
{
int
completed
=
0
;
int
completed
=
0
;
redisContext
*
c
=
&
(
ac
->
c
);
redisContext
*
c
=
&
(
ac
->
c
);
if
(
redis
FinishAsync
Connect
(
c
,
&
completed
)
==
REDIS_ERR
)
{
if
(
redis
Check
Connect
Done
(
c
,
&
completed
)
==
REDIS_ERR
)
{
/* Error! */
/* Error! */
redisCheckSocketError
(
c
);
redisCheckSocketError
(
c
);
if
(
ac
->
onConnect
)
ac
->
onConnect
(
ac
,
REDIS_ERR
);
if
(
ac
->
onConnect
)
ac
->
onConnect
(
ac
,
REDIS_ERR
);
...
...
net.c
View file @
cbe4ae63
...
@@ -221,8 +221,10 @@ static int redisContextWaitReady(redisContext *c, long msec) {
...
@@ -221,8 +221,10 @@ static int redisContextWaitReady(redisContext *c, long msec) {
return
REDIS_ERR
;
return
REDIS_ERR
;
}
}
if
(
redisCheckSocketError
(
c
)
!=
REDIS_OK
)
if
(
redisCheckConnectDone
(
c
,
&
res
)
!=
REDIS_OK
||
res
==
0
)
{
redisCheckSocketError
(
c
);
return
REDIS_ERR
;
return
REDIS_ERR
;
}
return
REDIS_OK
;
return
REDIS_OK
;
}
}
...
@@ -232,7 +234,7 @@ static int redisContextWaitReady(redisContext *c, long msec) {
...
@@ -232,7 +234,7 @@ static int redisContextWaitReady(redisContext *c, long msec) {
return
REDIS_ERR
;
return
REDIS_ERR
;
}
}
int
redis
FinishAsync
Connect
(
redisContext
*
c
,
int
*
completed
)
{
int
redis
Check
Connect
Done
(
redisContext
*
c
,
int
*
completed
)
{
int
rc
=
connect
(
c
->
fd
,
(
const
struct
sockaddr
*
)
c
->
saddr
,
c
->
addrlen
);
int
rc
=
connect
(
c
->
fd
,
(
const
struct
sockaddr
*
)
c
->
saddr
,
c
->
addrlen
);
if
(
rc
==
0
)
{
if
(
rc
==
0
)
{
*
completed
=
1
;
*
completed
=
1
;
...
@@ -410,8 +412,14 @@ addrretry:
...
@@ -410,8 +412,14 @@ addrretry:
if
(
errno
==
EHOSTUNREACH
)
{
if
(
errno
==
EHOSTUNREACH
)
{
redisContextCloseFd
(
c
);
redisContextCloseFd
(
c
);
continue
;
continue
;
}
else
if
(
errno
==
EINPROGRESS
&&
!
blocking
)
{
}
else
if
(
errno
==
EINPROGRESS
)
{
/* This is ok. */
if
(
blocking
)
{
goto
wait_for_ready
;
}
/* This is ok.
* Note that even when it's in blocking mode, we unset blocking
* for `connect()`
*/
}
else
if
(
errno
==
EADDRNOTAVAIL
&&
reuseaddr
)
{
}
else
if
(
errno
==
EADDRNOTAVAIL
&&
reuseaddr
)
{
if
(
++
reuses
>=
REDIS_CONNECT_RETRIES
)
{
if
(
++
reuses
>=
REDIS_CONNECT_RETRIES
)
{
goto
error
;
goto
error
;
...
@@ -420,6 +428,7 @@ addrretry:
...
@@ -420,6 +428,7 @@ addrretry:
goto
addrretry
;
goto
addrretry
;
}
}
}
else
{
}
else
{
wait_for_ready:
if
(
redisContextWaitReady
(
c
,
timeout_msec
)
!=
REDIS_OK
)
if
(
redisContextWaitReady
(
c
,
timeout_msec
)
!=
REDIS_OK
)
goto
error
;
goto
error
;
}
}
...
...
net.h
View file @
cbe4ae63
...
@@ -45,6 +45,6 @@ int redisContextConnectBindTcp(redisContext *c, const char *addr, int port,
...
@@ -45,6 +45,6 @@ int redisContextConnectBindTcp(redisContext *c, const char *addr, int port,
const
char
*
source_addr
);
const
char
*
source_addr
);
int
redisContextConnectUnix
(
redisContext
*
c
,
const
char
*
path
,
const
struct
timeval
*
timeout
);
int
redisContextConnectUnix
(
redisContext
*
c
,
const
char
*
path
,
const
struct
timeval
*
timeout
);
int
redisKeepAlive
(
redisContext
*
c
,
int
interval
);
int
redisKeepAlive
(
redisContext
*
c
,
int
interval
);
int
redis
FinishAsync
Connect
(
redisContext
*
c
,
int
*
completed
);
int
redis
Check
Connect
Done
(
redisContext
*
c
,
int
*
completed
);
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment