|
|
@ -29,6 +29,7 @@ struct connector_instance { |
|
|
|
proc_instance_t *pi; |
|
|
|
proc_instance_t *pi; |
|
|
|
int serverfd; |
|
|
|
int serverfd; |
|
|
|
int nfds; |
|
|
|
int nfds; |
|
|
|
|
|
|
|
bool accept; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
typedef struct connector_instance conn_instance_t; |
|
|
|
typedef struct connector_instance conn_instance_t; |
|
|
@ -93,6 +94,8 @@ void *acceptor(void *arg) |
|
|
|
retry: |
|
|
|
retry: |
|
|
|
client = ckzalloc(sizeof(client_instance_t)); |
|
|
|
client = ckzalloc(sizeof(client_instance_t)); |
|
|
|
client->address_len = sizeof(client->address); |
|
|
|
client->address_len = sizeof(client->address); |
|
|
|
|
|
|
|
while (!ci->accept) |
|
|
|
|
|
|
|
sleep(1); |
|
|
|
fd = accept(ci->serverfd, &client->address, &client->address_len); |
|
|
|
fd = accept(ci->serverfd, &client->address, &client->address_len); |
|
|
|
if (unlikely(fd < 0)) { |
|
|
|
if (unlikely(fd < 0)) { |
|
|
|
LOGERR("Failed to accept on socket %d in acceptor", ci->serverfd); |
|
|
|
LOGERR("Failed to accept on socket %d in acceptor", ci->serverfd); |
|
|
@ -480,6 +483,7 @@ retry: |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dealloc(buf); |
|
|
|
buf = recv_unix_msg(sockd); |
|
|
|
buf = recv_unix_msg(sockd); |
|
|
|
if (!buf) { |
|
|
|
if (!buf) { |
|
|
|
LOGWARNING("Failed to get message in connector_loop"); |
|
|
|
LOGWARNING("Failed to get message in connector_loop"); |
|
|
@ -490,6 +494,16 @@ retry: |
|
|
|
send_unix_msg(sockd, "pong"); |
|
|
|
send_unix_msg(sockd, "pong"); |
|
|
|
goto retry; |
|
|
|
goto retry; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!strncasecmp(buf, "accept", 6)) { |
|
|
|
|
|
|
|
LOGDEBUG("Connector received accept signal"); |
|
|
|
|
|
|
|
ci->accept = true; |
|
|
|
|
|
|
|
goto retry; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!strncasecmp(buf, "reject", 6)) { |
|
|
|
|
|
|
|
LOGDEBUG("Connector received reject signal"); |
|
|
|
|
|
|
|
ci->accept = false; |
|
|
|
|
|
|
|
goto retry; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("Connector received message: %s", buf); |
|
|
|
LOGDEBUG("Connector received message: %s", buf); |
|
|
|
if (!strncasecmp(buf, "shutdown", 8)) |
|
|
|
if (!strncasecmp(buf, "shutdown", 8)) |
|
|
|