Browse Source

Use cmdmatch in connector and ckpool

master
Con Kolivas 10 years ago
parent
commit
5d266a0faa
  1. 8
      src/ckpool.c
  2. 14
      src/connector.c

8
src/ckpool.c

@ -195,14 +195,14 @@ retry:
if (!buf) { if (!buf) {
LOGWARNING("Failed to get message in listener"); LOGWARNING("Failed to get message in listener");
send_unix_msg(sockd, "failed"); send_unix_msg(sockd, "failed");
} else if (!strncasecmp(buf, "shutdown", 8)) { } else if (cmdmatch(buf, "shutdown")) {
LOGWARNING("Listener received shutdown message, terminating ckpool"); LOGWARNING("Listener received shutdown message, terminating ckpool");
send_unix_msg(sockd, "exiting"); send_unix_msg(sockd, "exiting");
goto out; goto out;
} else if (!strncasecmp(buf, "ping", 4)) { } else if (cmdmatch(buf, "ping")) {
LOGDEBUG("Listener received ping request"); LOGDEBUG("Listener received ping request");
send_unix_msg(sockd, "pong"); send_unix_msg(sockd, "pong");
} else if (!strncasecmp(buf, "loglevel", 8)) { } else if (cmdmatch(buf, "loglevel")) {
int loglevel; int loglevel;
if (sscanf(buf, "loglevel=%d", &loglevel) != 1) { if (sscanf(buf, "loglevel=%d", &loglevel) != 1) {
@ -216,7 +216,7 @@ retry:
broadcast_proc(ckp, buf); broadcast_proc(ckp, buf);
send_unix_msg(sockd, "success"); send_unix_msg(sockd, "success");
} }
} else if (!strncasecmp(buf, "getfd", 5)) { } else if (cmdmatch(buf, "getfd")) {
char *msg; char *msg;
msg = send_recv_proc(ckp->connector, "getfd"); msg = send_recv_proc(ckp->connector, "getfd");

14
src/connector.c

@ -514,30 +514,30 @@ retry:
LOGWARNING("Failed to get message in connector_loop"); LOGWARNING("Failed to get message in connector_loop");
goto retry; goto retry;
} }
if (!strncasecmp(buf, "ping", 4)) { if (cmdmatch(buf, "ping")) {
LOGDEBUG("Connector received ping request"); LOGDEBUG("Connector received ping request");
send_unix_msg(sockd, "pong"); send_unix_msg(sockd, "pong");
goto retry; goto retry;
} }
if (!strncasecmp(buf, "accept", 6)) { if (cmdmatch(buf, "accept")) {
LOGDEBUG("Connector received accept signal"); LOGDEBUG("Connector received accept signal");
ci->accept = true; ci->accept = true;
goto retry; goto retry;
} }
if (!strncasecmp(buf, "reject", 6)) { if (cmdmatch(buf, "reject")) {
LOGDEBUG("Connector received reject signal"); LOGDEBUG("Connector received reject signal");
ci->accept = false; ci->accept = false;
goto retry; goto retry;
} }
if (!strncasecmp(buf, "loglevel", 8)) { if (cmdmatch(buf, "loglevel")) {
sscanf(buf, "loglevel=%d", &ckp->loglevel); sscanf(buf, "loglevel=%d", &ckp->loglevel);
goto retry; goto retry;
} }
LOGDEBUG("Connector received message: %s", buf); LOGDEBUG("Connector received message: %s", buf);
if (!strncasecmp(buf, "shutdown", 8)) if (cmdmatch(buf, "shutdown"))
goto out; goto out;
if (!strncasecmp(buf, "dropclient", 10)) { if (cmdmatch(buf, "dropclient")) {
client_instance_t *client; client_instance_t *client;
int client_id; int client_id;
@ -556,7 +556,7 @@ retry:
LOGINFO("Connector dropped client id: %d", client_id); LOGINFO("Connector dropped client id: %d", client_id);
goto retry; goto retry;
} }
if (!strncasecmp(buf, "getfd", 5)) { if (cmdmatch(buf, "getfd")) {
send_fd(ci->serverfd, sockd); send_fd(ci->serverfd, sockd);
goto retry; goto retry;
} }

Loading…
Cancel
Save