Skip to content

Commit

Permalink
make async interface throw the right exception, when getting null rep…
Browse files Browse the repository at this point in the history
…ly: issue #545
  • Loading branch information
sewenew committed Feb 11, 2024
1 parent 92c2ab3 commit f779c71
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/sw/redis++/async_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,15 @@ class CommandEvent : public AsyncEvent {
}
}

static void _reply_callback(redisAsyncContext * /*ctx*/, void *r, void *privdata) {
static void _reply_callback(redisAsyncContext *ctx, void *r, void *privdata) {
auto event = static_cast<CommandEvent<Result, ResultParser> *>(privdata);

assert(event != nullptr);
assert(event != nullptr && ctx != nullptr);

try {
redisReply *reply = static_cast<redisReply *>(r);
if (reply == nullptr) {
event->set_exception(std::make_exception_ptr(Error("connection has been closed")));
throw_error(ctx->c, "null reply");
} else if (reply::is_error(*reply)) {
try {
throw_error(*reply);
Expand Down Expand Up @@ -428,17 +428,17 @@ class AskingEvent : public AsyncEvent {
}

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);
assert(event != nullptr && ctx != 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) {
event->set_exception(std::make_exception_ptr(Error("connection has been closed")));
throw_error(ctx->c, "null reply");
} else if (reply::is_error(*reply)) {
try {
throw_error(*reply);
Expand Down Expand Up @@ -532,15 +532,15 @@ class ClusterEvent : public CommandEvent<Result, ResultParser> {
ASKING
};

static void _cluster_reply_callback(redisAsyncContext * /*ctx*/, void *r, void *privdata) {
static void _cluster_reply_callback(redisAsyncContext *ctx, void *r, void *privdata) {
auto event = static_cast<ClusterEvent<Result, ResultParser> *>(privdata);

assert(event != nullptr);
assert(event != nullptr && ctx != nullptr);

try {
redisReply *reply = static_cast<redisReply *>(r);
if (reply == nullptr) {
event->set_exception(std::make_exception_ptr(Error("connection has been closed")));
throw_error(ctx->c, "null reply");
} else if (reply::is_error(*reply)) {
try {
throw_error(*reply);
Expand Down

0 comments on commit f779c71

Please sign in to comment.