MINOR: cli/show_fd: report some easily detectable suspicious states
A file descriptor which maps to a connection but has more than one
thread in its mask, or an FD handle that doesn't correspond to the FD,
or wiht no mux context, or an FD with no thread in its mask, or with
more than 1 million events is flagged as suspicious.
diff --git a/src/cli.c b/src/cli.c
index ab5fe9a..4814663 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1061,10 +1061,17 @@
sv = objt_server(conn->target);
px = objt_proxy(conn->target);
is_back = conn_is_back(conn);
+ if (atleast2(fdt.thread_mask))
+ suspicious = 1;
+ if (conn->handle.fd != fd)
+ suspicious = 1;
}
else if (fdt.iocb == sock_accept_iocb)
li = fdt.owner;
+ if (!fdt.thread_mask)
+ suspicious = 1;
+
chunk_printf(&trash,
" %5d : st=0x%02x(R:%c%c W:%c%c) ev=0x%02x(%c%c%c%c%c) [%c%c] tmask=0x%lx umask=0x%lx owner=%p iocb=%p(",
fd,
@@ -1091,6 +1098,12 @@
}
else if (fdt.iocb == sock_conn_iocb) {
chunk_appendf(&trash, ") back=%d cflg=0x%08x", is_back, conn_flags);
+
+ if (conn->handle.fd != fd) {
+ chunk_appendf(&trash, " fd=%d(BOGUS)", conn->handle.fd);
+ suspicious = 1;
+ }
+
if (px)
chunk_appendf(&trash, " px=%s", px->id);
else if (sv)
@@ -1100,6 +1113,8 @@
if (mux) {
chunk_appendf(&trash, " mux=%s ctx=%p", mux->name, ctx);
+ if (!ctx)
+ suspicious = 1;
if (mux->show_fd)
suspicious |= mux->show_fd(&trash, fdt.owner);
}
@@ -1124,6 +1139,8 @@
#ifdef DEBUG_FD
chunk_appendf(&trash, " evcnt=%u", fdtab[fd].event_count);
+ if (fdtab[fd].event_count >= 1000000)
+ suspicious = 1;
#endif
chunk_appendf(&trash, "%s\n", suspicious ? " !" : "");