From 5d266a0faac0adc813e9d2998fb8bad71ba10b6c Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 2 Aug 2014 12:35:42 +1000 Subject: [PATCH] Use cmdmatch in connector and ckpool --- src/ckpool.c | 8 ++++---- src/connector.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ckpool.c b/src/ckpool.c index 5b212564..9f9d333a 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -195,14 +195,14 @@ retry: if (!buf) { LOGWARNING("Failed to get message in listener"); send_unix_msg(sockd, "failed"); - } else if (!strncasecmp(buf, "shutdown", 8)) { + } else if (cmdmatch(buf, "shutdown")) { LOGWARNING("Listener received shutdown message, terminating ckpool"); send_unix_msg(sockd, "exiting"); goto out; - } else if (!strncasecmp(buf, "ping", 4)) { + } else if (cmdmatch(buf, "ping")) { LOGDEBUG("Listener received ping request"); send_unix_msg(sockd, "pong"); - } else if (!strncasecmp(buf, "loglevel", 8)) { + } else if (cmdmatch(buf, "loglevel")) { int loglevel; if (sscanf(buf, "loglevel=%d", &loglevel) != 1) { @@ -216,7 +216,7 @@ retry: broadcast_proc(ckp, buf); send_unix_msg(sockd, "success"); } - } else if (!strncasecmp(buf, "getfd", 5)) { + } else if (cmdmatch(buf, "getfd")) { char *msg; msg = send_recv_proc(ckp->connector, "getfd"); diff --git a/src/connector.c b/src/connector.c index 7ea47e6f..466cf5de 100644 --- a/src/connector.c +++ b/src/connector.c @@ -514,30 +514,30 @@ retry: LOGWARNING("Failed to get message in connector_loop"); goto retry; } - if (!strncasecmp(buf, "ping", 4)) { + if (cmdmatch(buf, "ping")) { LOGDEBUG("Connector received ping request"); send_unix_msg(sockd, "pong"); goto retry; } - if (!strncasecmp(buf, "accept", 6)) { + if (cmdmatch(buf, "accept")) { LOGDEBUG("Connector received accept signal"); ci->accept = true; goto retry; } - if (!strncasecmp(buf, "reject", 6)) { + if (cmdmatch(buf, "reject")) { LOGDEBUG("Connector received reject signal"); ci->accept = false; goto retry; } - if (!strncasecmp(buf, "loglevel", 8)) { + if (cmdmatch(buf, "loglevel")) { sscanf(buf, "loglevel=%d", &ckp->loglevel); goto retry; } LOGDEBUG("Connector received message: %s", buf); - if (!strncasecmp(buf, "shutdown", 8)) + if (cmdmatch(buf, "shutdown")) goto out; - if (!strncasecmp(buf, "dropclient", 10)) { + if (cmdmatch(buf, "dropclient")) { client_instance_t *client; int client_id; @@ -556,7 +556,7 @@ retry: LOGINFO("Connector dropped client id: %d", client_id); goto retry; } - if (!strncasecmp(buf, "getfd", 5)) { + if (cmdmatch(buf, "getfd")) { send_fd(ci->serverfd, sockd); goto retry; }