|
|
@ -280,10 +280,10 @@ retry: |
|
|
|
if (newfd > 0) { |
|
|
|
if (newfd > 0) { |
|
|
|
LOGDEBUG("Sending new fd %d", newfd); |
|
|
|
LOGDEBUG("Sending new fd %d", newfd); |
|
|
|
send_fd(newfd, sockd); |
|
|
|
send_fd(newfd, sockd); |
|
|
|
close(newfd); |
|
|
|
Close(newfd); |
|
|
|
} else |
|
|
|
} else |
|
|
|
LOGWARNING("Failed to get_fd"); |
|
|
|
LOGWARNING("Failed to get_fd"); |
|
|
|
close(connfd); |
|
|
|
Close(connfd); |
|
|
|
} else |
|
|
|
} else |
|
|
|
LOGWARNING("Failed to send_procmsg to connector"); |
|
|
|
LOGWARNING("Failed to send_procmsg to connector"); |
|
|
|
} else if (cmdmatch(buf, "restart")) { |
|
|
|
} else if (cmdmatch(buf, "restart")) { |
|
|
@ -300,7 +300,7 @@ retry: |
|
|
|
LOGINFO("Listener received unhandled message: %s", buf); |
|
|
|
LOGINFO("Listener received unhandled message: %s", buf); |
|
|
|
send_unix_msg(sockd, "unknown"); |
|
|
|
send_unix_msg(sockd, "unknown"); |
|
|
|
} |
|
|
|
} |
|
|
|
close(sockd); |
|
|
|
Close(sockd); |
|
|
|
goto retry; |
|
|
|
goto retry; |
|
|
|
out: |
|
|
|
out: |
|
|
|
dealloc(buf); |
|
|
|
dealloc(buf); |
|
|
@ -386,10 +386,7 @@ int read_socket_line(connsock_t *cs, int timeout) |
|
|
|
out: |
|
|
|
out: |
|
|
|
if (ret < 0) { |
|
|
|
if (ret < 0) { |
|
|
|
dealloc(cs->buf); |
|
|
|
dealloc(cs->buf); |
|
|
|
if (cs->fd > 0) { |
|
|
|
Close(cs->fd); |
|
|
|
close(cs->fd); |
|
|
|
|
|
|
|
cs->fd = -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
@ -447,7 +444,7 @@ bool _send_proc(proc_instance_t *pi, const char *msg, const char *file, const ch |
|
|
|
LOGWARNING("Failed to send %s to socket %s", msg, path); |
|
|
|
LOGWARNING("Failed to send %s to socket %s", msg, path); |
|
|
|
else |
|
|
|
else |
|
|
|
ret = true; |
|
|
|
ret = true; |
|
|
|
close(sockd); |
|
|
|
Close(sockd); |
|
|
|
out: |
|
|
|
out: |
|
|
|
if (unlikely(!ret)) { |
|
|
|
if (unlikely(!ret)) { |
|
|
|
LOGERR("Failure in send_proc from %s %s:%d", file, func, line); |
|
|
|
LOGERR("Failure in send_proc from %s %s:%d", file, func, line); |
|
|
@ -484,7 +481,7 @@ char *_send_recv_proc(proc_instance_t *pi, const char *msg, const char *file, co |
|
|
|
LOGWARNING("Failed to send %s to socket %s", msg, path); |
|
|
|
LOGWARNING("Failed to send %s to socket %s", msg, path); |
|
|
|
else |
|
|
|
else |
|
|
|
buf = recv_unix_msg(sockd); |
|
|
|
buf = recv_unix_msg(sockd); |
|
|
|
close(sockd); |
|
|
|
Close(sockd); |
|
|
|
out: |
|
|
|
out: |
|
|
|
if (unlikely(!buf)) |
|
|
|
if (unlikely(!buf)) |
|
|
|
LOGERR("Failure in send_recv_proc from %s %s:%d", file, func, line); |
|
|
|
LOGERR("Failure in send_recv_proc from %s %s:%d", file, func, line); |
|
|
@ -515,7 +512,7 @@ char *_send_recv_ckdb(const ckpool_t *ckp, const char *msg, const char *file, co |
|
|
|
LOGWARNING("Failed to send %s to ckdb", msg); |
|
|
|
LOGWARNING("Failed to send %s to ckdb", msg); |
|
|
|
else |
|
|
|
else |
|
|
|
buf = recv_unix_msg(sockd); |
|
|
|
buf = recv_unix_msg(sockd); |
|
|
|
close(sockd); |
|
|
|
Close(sockd); |
|
|
|
out: |
|
|
|
out: |
|
|
|
if (unlikely(!buf)) |
|
|
|
if (unlikely(!buf)) |
|
|
|
LOGERR("Failure in send_recv_ckdb from %s %s:%d", file, func, line); |
|
|
|
LOGERR("Failure in send_recv_ckdb from %s %s:%d", file, func, line); |
|
|
@ -608,7 +605,7 @@ out_empty: |
|
|
|
/* Assume that a failed request means the socket will be closed
|
|
|
|
/* Assume that a failed request means the socket will be closed
|
|
|
|
* and reopen it */ |
|
|
|
* and reopen it */ |
|
|
|
LOGWARNING("Reopening socket to %s:%s", cs->url, cs->port); |
|
|
|
LOGWARNING("Reopening socket to %s:%s", cs->url, cs->port); |
|
|
|
close(cs->fd); |
|
|
|
Close(cs->fd); |
|
|
|
cs->fd = connect_socket(cs->url, cs->port); |
|
|
|
cs->fd = connect_socket(cs->url, cs->port); |
|
|
|
} |
|
|
|
} |
|
|
|
out: |
|
|
|
out: |
|
|
@ -1313,12 +1310,12 @@ int main(int argc, char **argv) |
|
|
|
if (sockd > 0 && send_unix_msg(sockd, "getfd")) { |
|
|
|
if (sockd > 0 && send_unix_msg(sockd, "getfd")) { |
|
|
|
ckp.oldconnfd = get_fd(sockd); |
|
|
|
ckp.oldconnfd = get_fd(sockd); |
|
|
|
|
|
|
|
|
|
|
|
close(sockd); |
|
|
|
Close(sockd); |
|
|
|
sockd = open_unix_client(ckp.main.us.path); |
|
|
|
sockd = open_unix_client(ckp.main.us.path); |
|
|
|
send_unix_msg(sockd, "shutdown"); |
|
|
|
send_unix_msg(sockd, "shutdown"); |
|
|
|
if (ckp.oldconnfd > 0) |
|
|
|
if (ckp.oldconnfd > 0) |
|
|
|
LOGWARNING("Inherited old socket with new file descriptor %d!", ckp.oldconnfd); |
|
|
|
LOGWARNING("Inherited old socket with new file descriptor %d!", ckp.oldconnfd); |
|
|
|
close(sockd); |
|
|
|
Close(sockd); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|