Skip to content

Commit

Permalink
Merge pull request #131 from p-alik/redis-issue-129
Browse files Browse the repository at this point in the history
ensure data/priority position in hgetall result

Reviewed-by: Clint Byrum <clint@fewbar.com>
             https://github.com/SpamapS
  • Loading branch information
bonnyci[bot] authored Jul 24, 2017
2 parents 3b1621f + 5f9fcc3 commit 71a6995
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions libgearman-server/plugins/queue/redis/queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,19 @@ bool gearmand::plugins::queue::Hiredis::fetch(char *key, gearmand::plugins::queu
} else {
// 2 x (key + value)
assert(reply->elements == 4);
std::string s{reply->element[1]->str};
req.data = s;
req.priority = (uint32_t)std::stoi(reply->element[3]->str);
auto fk = reply->element[0]->str;
if(strcmp(fk, "data") == 0) {
std::string s{reply->element[1]->str};
req.data = s;
req.priority = (uint32_t)std::stoi(reply->element[3]->str);
} else if (strcmp(fk, "priority") == 0) {
std::string s{reply->element[3]->str};
req.data = s;
req.priority = (uint32_t)std::stoi(reply->element[1]->str);
} else {
gearmand_log_error(GEARMAN_DEFAULT_LOG_PARAM, "unexpected key %s", fk);
return false;
}
}

freeReplyObject(reply);
Expand Down

0 comments on commit 71a6995

Please sign in to comment.