|
|
@ -74,6 +74,7 @@ void logmsg(int loglevel, const char *fmt, ...) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Listen for incoming global requests. Always returns a response if possible */ |
|
|
|
static void *listener(void *arg) |
|
|
|
static void *listener(void *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
proc_instance_t *pi = (proc_instance_t *)arg; |
|
|
|
proc_instance_t *pi = (proc_instance_t *)arg; |
|
|
@ -86,8 +87,6 @@ retry: |
|
|
|
dealloc(buf); |
|
|
|
dealloc(buf); |
|
|
|
sockd = accept(us->sockd, NULL, NULL); |
|
|
|
sockd = accept(us->sockd, NULL, NULL); |
|
|
|
if (sockd < 0) { |
|
|
|
if (sockd < 0) { |
|
|
|
if (interrupted()) |
|
|
|
|
|
|
|
goto retry; |
|
|
|
|
|
|
|
LOGERR("Failed to accept on socket in listener"); |
|
|
|
LOGERR("Failed to accept on socket in listener"); |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
@ -95,17 +94,16 @@ retry: |
|
|
|
buf = recv_unix_msg(sockd); |
|
|
|
buf = recv_unix_msg(sockd); |
|
|
|
if (!buf) { |
|
|
|
if (!buf) { |
|
|
|
LOGWARNING("Failed to get message in listener"); |
|
|
|
LOGWARNING("Failed to get message in listener"); |
|
|
|
close(sockd); |
|
|
|
} else if (!strncasecmp(buf, "shutdown", 8)) { |
|
|
|
goto retry; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!strncasecmp(buf, "shutdown", 8)) { |
|
|
|
|
|
|
|
LOGWARNING("Listener received shutdown message, terminating ckpool"); |
|
|
|
LOGWARNING("Listener received shutdown message, terminating ckpool"); |
|
|
|
close(sockd); |
|
|
|
send_unix_msg(sockd, "exiting"); |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} else if (!strncasecmp(buf, "ping", 4)) { |
|
|
|
if (!strncasecmp(buf, "ping", 4)) { |
|
|
|
|
|
|
|
LOGDEBUG("Listener received ping request"); |
|
|
|
LOGDEBUG("Listener received ping request"); |
|
|
|
send_unix_msg(sockd, "pong"); |
|
|
|
send_unix_msg(sockd, "pong"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
LOGINFO("Listener received unhandled message: %s", buf); |
|
|
|
|
|
|
|
send_unix_msg(sockd, "unknown"); |
|
|
|
} |
|
|
|
} |
|
|
|
close(sockd); |
|
|
|
close(sockd); |
|
|
|
goto retry; |
|
|
|
goto retry; |
|
|
|