]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: flags/mux-fcgi: Decode FCGI connection and stream flags
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 12 Oct 2022 15:00:13 +0000 (17:00 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 12 Oct 2022 15:10:41 +0000 (17:10 +0200)
The new functions fconn_show_flags() and fstrm_show_flags() decode the flags
state into a string, and are used by dev/flags:

$ /dev/flags/flags fconn 0x3100
fconn->flags = FCGI_CF_GET_VALUES | FCGI_CF_KEEP_CONN | FCGI_CF_MPXS_CONNS

./dev/flags/flags fstrm  0x3300
fstrm->flags = FCGI_SF_WANT_SHUTW | FCGI_SF_WANT_SHUTR | FCGI_SF_OUTGOING_DATA | FCGI_SF_BEGIN_SENT

dev/flags/flags.c
include/haproxy/mux_fcgi-t.h

index c0cc067f4c51a8d49e9fe545669492d3b2b0f893..7ec34f4e95b0429e406456280b6a3dacf89d48f0 100644 (file)
@@ -6,6 +6,7 @@
 #include <haproxy/fd-t.h>
 #include <haproxy/http_ana-t.h>
 #include <haproxy/htx-t.h>
+#include <haproxy/mux_fcgi-t.h>
 #include <haproxy/mux_h2-t.h>
 #include <haproxy/mux_h1-t.h>
 #include <haproxy/stconn-t.h>
 #define SHOW_AS_H2S   0x00004000
 #define SHOW_AS_H1C   0x00008000
 #define SHOW_AS_H1S   0x00010000
+#define SHOW_AS_FCONN 0x00020000
+#define SHOW_AS_FSTRM 0x00040000
 
 // command line names, must be in exact same order as the SHOW_AS_* flags above
 // so that show_as_words[i] matches flag 1U<<i.
-const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", "hsl", "htx", "hmsg", "fd", "h2c", "h2s",  "h1c", "h1s", };
+const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", "hsl", "htx", "hmsg", "fd", "h2c", "h2s",  "h1c", "h1s", "fconn", "fstrm"};
 
 /* will be sufficient for even largest flag names */
 static char buf[4096];
@@ -144,6 +147,8 @@ int main(int argc, char **argv)
                if (show_as & SHOW_AS_H2S)   printf("h2s->flags = %s\n",  (h2s_show_flags    (buf, bsz, " | ", flags), buf));
                if (show_as & SHOW_AS_H1C)   printf("h1c->flags = %s\n",  (h1c_show_flags    (buf, bsz, " | ", flags), buf));
                if (show_as & SHOW_AS_H1S)   printf("h1s->flags = %s\n",  (h1s_show_flags    (buf, bsz, " | ", flags), buf));
+               if (show_as & SHOW_AS_FCONN) printf("fconn->flags = %s\n",(fconn_show_flags  (buf, bsz, " | ", flags), buf));
+               if (show_as & SHOW_AS_FSTRM) printf("fstrm->flags = %s\n",(fstrm_show_flags  (buf, bsz, " | ", flags), buf));
        }
        return 0;
 }
index 75b26d2991b6fe0b925dbf05d1d415a33b1c03ad..a321f62f53cf5d6e1c1ecb384b92727cb936150a 100644 (file)
@@ -23,6 +23,7 @@
 #define _HAPROXY_MUX_FCGI_T_H
 
 #include <haproxy/api-t.h>
+#include <haproxy/show_flags-t.h>
 
 /**** FCGI connection flags (32 bit), in fcgi_conn->flags ****/
 #define FCGI_CF_NONE           0x00000000
 #define FCGI_CF_KEEP_CONN       0x00001000  /* HAProxy is responsible to close the connection */
 #define FCGI_CF_GET_VALUES      0x00002000  /* retrieve settings */
 
+/* This function is used to report flags in debugging tools. Please reflect
+ * below any single-bit flag addition above in the same order via the
+ * __APPEND_FLAG macro. The new end of the buffer is returned.
+ */
+static forceinline char *fconn_show_flags(char *buf, size_t len, const char *delim, uint flg)
+{
+#define _(f, ...) __APPEND_FLAG(buf, len, delim, flg, f, #f, __VA_ARGS__)
+       /* prologue */
+       _(0);
+       /* flags */
+       _(FCGI_CF_MUX_MALLOC, _(FCGI_CF_MUX_MFULL,
+       _(FCGI_CF_DEM_DALLOC, _(FCGI_CF_DEM_DFULL, _(FCGI_CF_DEM_MROOM,
+       _(FCGI_CF_DEM_SALLOC, _(FCGI_CF_DEM_SFULL, _(FCGI_CF_DEM_TOOMANY,
+       _(FCGI_CF_MPXS_CONNS, _(FCGI_CF_ABRTS_SENT, _(FCGI_CF_ABRTS_FAILED,
+       _(FCGI_CF_WAIT_FOR_HS, _(FCGI_CF_KEEP_CONN, _(FCGI_CF_GET_VALUES))))))))))))));
+       /* epilogue */
+       _(~0U);
+       return buf;
+#undef _
+}
+
 /**** FCGI stream flags (32 bit), in fcgi_strm->flags ****/
 #define FCGI_SF_NONE           0x00000000
 #define FCGI_SF_ES_RCVD        0x00000001 /* end-of-stream received (empty STDOUT or EDN_REQUEST record) */
 #define FCGI_SF_WANT_SHUTR     0x00001000  /* a stream couldn't shutr() (mux full/busy) */
 #define FCGI_SF_WANT_SHUTW     0x00002000  /* a stream couldn't shutw() (mux full/busy) */
 
+/* This function is used to report flags in debugging tools. Please reflect
+ * below any single-bit flag addition above in the same order via the
+ * __APPEND_FLAG macro. The new end of the buffer is returned.
+ */
+static forceinline char *fstrm_show_flags(char *buf, size_t len, const char *delim, uint flg)
+{
+#define _(f, ...) __APPEND_FLAG(buf, len, delim, flg, f, #f, __VA_ARGS__)
+       /* prologue */
+       _(0);
+       /* flags */
+       _(FCGI_SF_ES_RCVD, _(FCGI_SF_ES_SENT, _(FCGI_SF_EP_SENT, _(FCGI_SF_ABRT_SENT,
+       _(FCGI_SF_BLK_MBUSY, _(FCGI_SF_BLK_MROOM,
+       _(FCGI_SF_BEGIN_SENT, _(FCGI_SF_OUTGOING_DATA, _(FCGI_SF_NOTIFIED,
+       _(FCGI_SF_WANT_SHUTR, _(FCGI_SF_WANT_SHUTW)))))))))));
+       /* epilogue */
+       _(~0U);
+       return buf;
+#undef _
+}
+
 /* FCGI connection state (fcgi_conn->state) */
 enum fcgi_conn_st {
        FCGI_CS_INIT = 0,    /* init done, waiting for sending GET_VALUES record */