From 5f9fcc3d742d8e94fdd50b191e95b63b5bfdfdba Mon Sep 17 00:00:00 2001 From: Alexei Pastuchov Date: Mon, 24 Jul 2017 13:38:06 +0200 Subject: [PATCH] ensure data/priority position in hgetall result https://github.com/gearman/gearmand/issues/129 --- libgearman-server/plugins/queue/redis/queue.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libgearman-server/plugins/queue/redis/queue.cc b/libgearman-server/plugins/queue/redis/queue.cc index 7e48b4c5e..c232554c3 100644 --- a/libgearman-server/plugins/queue/redis/queue.cc +++ b/libgearman-server/plugins/queue/redis/queue.cc @@ -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);