summaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorArseniy Simonov <harvos.arsen@gmail.com>2021-10-03 15:06:40 +0000
committerMichael Grunder <michael.grunder@gmail.com>2022-08-29 16:22:20 -0700
commit75cb6c1ea6054db7cc71c05181c30d1c439867b7 (patch)
tree8139d4ce098e59ea2ead1de13a767265b8b50b89 /net.c
parentc57cad658d43973bc1f0609649ef90b104262d75 (diff)
Do store command timeout in the context for redisSetTimeout (#593)
Diffstat (limited to 'net.c')
-rw-r--r--net.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net.c b/net.c
index 3ff89ed..8378c28 100644
--- a/net.c
+++ b/net.c
@@ -50,6 +50,8 @@
/* Defined in hiredis.c */
void __redisSetError(redisContext *c, int type, const char *str);
+int redisContextUpdateCommandTimeout(redisContext *c, const struct timeval *timeout);
+
void redisNetClose(redisContext *c) {
if (c && c->fd != REDIS_INVALID_FD) {
close(c->fd);
@@ -333,6 +335,10 @@ int redisContextSetTimeout(redisContext *c, const struct timeval tv) {
const void *to_ptr = &tv;
size_t to_sz = sizeof(tv);
+ if (redisContextUpdateCommandTimeout(c, &tv) != REDIS_OK) {
+ __redisSetError(c, REDIS_ERR_OOM, "Out of memory");
+ return REDIS_ERR;
+ }
if (setsockopt(c->fd,SOL_SOCKET,SO_RCVTIMEO,to_ptr,to_sz) == -1) {
__redisSetErrorFromErrno(c,REDIS_ERR_IO,"setsockopt(SO_RCVTIMEO)");
return REDIS_ERR;