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) {
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");

14
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;
}

Loading…
Cancel
Save