From f35f54a6428a99bacad6daedbd7cd8367c985242 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 24 Feb 2016 09:36:41 +1100 Subject: [PATCH] Revert "Microoptimise ckdbq_process" This reverts commit 5c09f0608f314a501debd1235b33c333dbe0c03e. Conflicts: src/stratifier.c --- src/stratifier.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 42bbbd3e..e9afeb99 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -6779,7 +6779,7 @@ static bool test_and_clear(bool *val, mutex_t *lock) static void ckdbq_process(ckpool_t *ckp, char *msg) { sdata_t *sdata = ckp->sdata; - size_t responselen; + size_t responselen = 0; char *buf = NULL; while (!buf) { @@ -6799,15 +6799,16 @@ static void ckdbq_process(ckpool_t *ckp, char *msg) /* Process any requests from ckdb that are heartbeat responses with * specific requests. */ - responselen = strlen(buf); - if (likely(responselen > 1)) { + if (likely(buf)) + responselen = strlen(buf); + if (likely(responselen > 0)) { char *response = alloca(responselen); int offset = 0; memset(response, 0, responselen); - if (likely(sscanf(buf, "%*d.%*d.%c%n", response, &offset) > 0)) { - strcpy(response + 1, buf + offset); - if (likely(safecmp(response, "ok"))) { + if (sscanf(buf, "%*d.%*d.%c%n", response, &offset) > 0) { + strcpy(response+1, buf+offset); + if (safecmp(response, "ok")) { char *cmd; cmd = response; @@ -6821,8 +6822,8 @@ static void ckdbq_process(ckpool_t *ckp, char *msg) LOGWARNING("Got ckdb failure response: %s", buf); } else LOGWARNING("Got bad ckdb response: %s", buf); + free(buf); } - free(buf); } static int transactions_by_jobid(sdata_t *sdata, const int64_t id)