Skip to content

Commit 6fa030b

Browse files
committed
we should not clear the timeout error in normal case, and only clear it when consuming published message
1 parent b4d1d0a commit 6fa030b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/sw/redis++/connection.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ class Connection {
101101
return _ctx->err != REDIS_OK;
102102
}
103103

104+
void reset() noexcept {
105+
_ctx->err = 0;
106+
}
107+
104108
void reconnect();
105109

106110
auto last_active() const

src/sw/redis++/errors.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ void throw_error(redisContext &context, const std::string &err_info) {
4949

5050
switch (err_code) {
5151
case REDIS_ERR_IO:
52-
if (errno == EAGAIN) {
53-
context.err = 0;
52+
if (errno == EAGAIN || errno == EINTR) {
5453
throw TimeoutError(err_msg);
5554
} else {
5655
throw IoError(err_msg);

src/sw/redis++/subscriber.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ void Subscriber::punsubscribe(const StringView &pattern) {
7676
void Subscriber::consume() {
7777
_check_connection();
7878

79-
auto reply = _connection.recv();
79+
ReplyUPtr reply;
80+
try {
81+
reply = _connection.recv();
82+
} catch (const TimeoutError &) {
83+
_connection.reset();
84+
throw;
85+
}
8086

8187
assert(reply);
8288

0 commit comments

Comments
 (0)