Skip to content

Commit

Permalink
bug fix: send command immediately after sending ASKING
Browse files Browse the repository at this point in the history
  • Loading branch information
sewenew committed Oct 12, 2021
1 parent dc8e650 commit ffe9ed1
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/sw/redis++/async_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,28 @@ class AskingEvent : public AsyncEvent {
if (redisAsyncCommand(&ctx, _asking_callback, this, "ASKING") != REDIS_OK) {
throw_error(ctx.c, "failed to send ASKING command");
}
}

virtual void set_exception(std::exception_ptr err) override {
assert(_event != nullptr);

_event->set_exception(err);
_event->handle(ctx);

_event = nullptr;
}

virtual void set_exception(std::exception_ptr err) override {
if (_event != nullptr) {
_event->set_exception(err);
}
}

private:
static void _asking_callback(redisAsyncContext *ctx, void *r, void *privdata) {
static void _asking_callback(redisAsyncContext * /*ctx*/, void *r, void *privdata) {
auto event = static_cast<AskingEvent *>(privdata);

assert(event != nullptr);

// TODO: No need to check the reply. It seems that we can simply ignore the reply,
// and delete the event.
try {
redisReply *reply = static_cast<redisReply *>(r);
if (reply == nullptr) {
Expand All @@ -332,15 +340,6 @@ class AskingEvent : public AsyncEvent {
}
} else {
reply::parse<void>(*reply);

assert(ctx != nullptr);
auto *context = static_cast<AsyncContext *>(ctx->data);
assert(context != nullptr);
auto &conn = context->connection;
assert(conn);

conn->send(AsyncEventUPtr(event->_event));
event->_event = nullptr;
}
} catch (...) {
event->set_exception(std::current_exception());
Expand Down

0 comments on commit ffe9ed1

Please sign in to comment.