"debug dev fd" scans the FDs of the process as the calling thread sees
them, and reports the ones unknown to fdtab. With per-thread-group FD
tables, both that scan and the fdtab lookups only reflect the view of
the calling thread's group: the same command may report different FDs
depending on the thread that serves it. Let's print the current tgid in
a header line so the output states which view it shows.
/* CLI state for "debug dev fd" */
struct dev_fd_ctx {
int start_fd;
+ int hdr_done;
};
/* CLI parser for the "debug dev fd" command. The current FD to restart from is
thread_isolate();
+ /* thread groups may have their own FD tables, and even their own view
+ * of the process's FDs, so let's always indicate which group the dump
+ * is seen from.
+ */
+ if (!ctx->hdr_done) {
+ chunk_printf(&trash, "# current tgid: %u\n", tgid);
+ if (applet_putchk(appctx, &trash) == -1) {
+ ret = 0;
+ goto leave;
+ }
+ ctx->hdr_done = 1;
+ }
+
/* we have two inner loops here, one for the proxy, the other one for
* the buffer.
*/
}
}
+ leave:
thread_release();
return ret;
}