MINOR: cli: warning on _getsocks when socket were closed
The previous attempt was reverted because it would emit a warning when
the sockets are still in the process when a reload failed, so this was
an expected 2nd try.
This warning however, will be displayed if a new process successfully
get the previous sockets AND the sendable number of sockets is 0.
This way the user will be warned if he tried to get the sockets fromt
the wrong process.
diff --git a/src/cli.c b/src/cli.c
index 4724ba4..c2ca84d 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1981,6 +1981,7 @@
/* Send all the bound sockets, always returns 1 */
static int _getsocks(char **args, char *payload, struct appctx *appctx, void *private)
{
+ static int already_sent = 0;
char *cmsgbuf = NULL;
unsigned char *tmpbuf = NULL;
struct cmsghdr *cmsg;
@@ -2036,8 +2037,11 @@
for (cur_fd = 0;cur_fd < global.maxsock; cur_fd++)
tot_fd_nb += !!(fdtab[cur_fd].state & FD_EXPORTED);
- if (tot_fd_nb == 0)
+ if (tot_fd_nb == 0) {
+ if (already_sent)
+ ha_warning("_getsocks: attempt to get sockets but they were already sent and closed in this process!\n");
goto out;
+ }
/* First send the total number of file descriptors, so that the
* receiving end knows what to expect.
@@ -2144,6 +2148,8 @@
}
}
+ already_sent = 1;
+
/* flush pending stuff */
if (nb_queued) {
iov.iov_len = curoff;