Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
5aa2397f
Commit
5aa2397f
authored
Apr 11, 2019
by
Mark Nunberg
Browse files
fix blocking timeouts on SSL reads/writes
parent
dc3c6ce8
Changes
1
Show whitespace changes
Inline
Side-by-side
sslio.c
View file @
5aa2397f
...
...
@@ -4,6 +4,7 @@
#include <assert.h>
#ifdef HIREDIS_SSL
#include <pthread.h>
#include <errno.h>
void
__redisSetError
(
redisContext
*
c
,
int
type
,
const
char
*
str
);
...
...
@@ -184,6 +185,28 @@ int redisSslRead(redisContext *c, char *buf, size_t bufcap) {
return
-
1
;
}
else
{
int
err
=
SSL_get_error
(
c
->
ssl
->
ssl
,
nread
);
if
(
c
->
flags
&
REDIS_BLOCK
)
{
/**
* In blocking mode, we should never end up in a situation where
* we get an error without it being an actual error, except
* in the case of EINTR, which can be spuriously received from
* debuggers or whatever.
*/
if
(
errno
==
EINTR
)
{
return
0
;
}
else
{
const
char
*
msg
=
NULL
;
if
(
errno
==
EAGAIN
)
{
msg
=
"Timed out"
;
}
__redisSetError
(
c
,
REDIS_ERR_IO
,
msg
);
return
-
1
;
}
}
/**
* We can very well get an EWOULDBLOCK/EAGAIN, however
*/
if
(
maybeCheckWant
(
c
->
ssl
,
err
))
{
return
0
;
}
else
{
...
...
@@ -203,7 +226,7 @@ int redisSslWrite(redisContext *c) {
c
->
ssl
->
lastLen
=
len
;
int
err
=
SSL_get_error
(
c
->
ssl
->
ssl
,
rv
);
if
(
maybeCheckWant
(
c
->
ssl
,
err
))
{
if
(
(
c
->
flags
&
REDIS_BLOCK
)
==
0
&&
maybeCheckWant
(
c
->
ssl
,
err
))
{
return
0
;
}
else
{
__redisSetError
(
c
,
REDIS_ERR_IO
,
NULL
);
...
...
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