]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: spoe: export the list of SPOP error reasons
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 22 Jul 2024 16:57:00 +0000 (18:57 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 24 Jul 2024 12:19:10 +0000 (14:19 +0200)
The strings representing the human-readable version for SPOP errors are now
exported. It is now an array of IST to ease manipulation.

include/haproxy/spoe.h
src/mux_spop.c

index 37f00ef68e3583a201887c034508c6d7bb017ba1..585b8bff9e2c5c46cefff6ef7ca4ea343c96faf1 100644 (file)
@@ -29,6 +29,7 @@
 
 struct appctx;
 
+extern const struct ist spop_err_reasons[SPOP_ERR_ENTRIES];
 extern const struct spop_version spop_supported_versions[];
 
 struct spoe_agent *spoe_appctx_agent(struct appctx *appctx);
index e660f473367c2b9c3abe8d8ee0f78dc2ab48a039..8147e711e8480666a3dbb8e64e4b766c33322348 100644 (file)
@@ -213,22 +213,22 @@ DECLARE_STATIC_POOL(pool_head_spop_conn, "spop_conn", sizeof(struct spop_conn));
 DECLARE_STATIC_POOL(pool_head_spop_strm, "spop_strm", sizeof(struct spop_strm));
 
 
-const char *spop_err_reasons[SPOP_ERR_ENTRIES] = {
-       [SPOP_ERR_NONE]               = "normal",
-       [SPOP_ERR_IO]                 = "I/O error",
-       [SPOP_ERR_TOUT]               = "a timeout occurred",
-       [SPOP_ERR_TOO_BIG]            = "frame is too big",
-       [SPOP_ERR_INVALID]            = "invalid frame received",
-       [SPOP_ERR_NO_VSN]             = "version value not found",
-       [SPOP_ERR_NO_FRAME_SIZE]      = "max-frame-size value not found",
-       [SPOP_ERR_NO_CAP]             = "capabilities value not found",
-       [SPOP_ERR_BAD_VSN]            = "unsupported version",
-       [SPOP_ERR_BAD_FRAME_SIZE]     = "max-frame-size too big or too small",
-       [SPOP_ERR_FRAG_NOT_SUPPORTED] = "fragmentation not supported",
-       [SPOP_ERR_INTERLACED_FRAMES]  = "invalid interlaced frames",
-       [SPOP_ERR_FRAMEID_NOTFOUND]   = "frame-id not found",
-       [SPOP_ERR_RES]                = "resource allocation error",
-       [SPOP_ERR_UNKNOWN]            = "an unknown error occurred",
+const struct ist spop_err_reasons[SPOP_ERR_ENTRIES] = {
+       [SPOP_ERR_NONE]               = IST("normal"),
+       [SPOP_ERR_IO]                 = IST("I/O error"),
+       [SPOP_ERR_TOUT]               = IST("a timeout occurred"),
+       [SPOP_ERR_TOO_BIG]            = IST("frame is too big"),
+       [SPOP_ERR_INVALID]            = IST("invalid frame received"),
+       [SPOP_ERR_NO_VSN]             = IST("version value not found"),
+       [SPOP_ERR_NO_FRAME_SIZE]      = IST("max-frame-size value not found"),
+       [SPOP_ERR_NO_CAP]             = IST("capabilities value not found"),
+       [SPOP_ERR_BAD_VSN]            = IST("unsupported version"),
+       [SPOP_ERR_BAD_FRAME_SIZE]     = IST("max-frame-size too big or too small"),
+       [SPOP_ERR_FRAG_NOT_SUPPORTED] = IST("fragmentation not supported"),
+       [SPOP_ERR_INTERLACED_FRAMES]  = IST("invalid interlaced frames"),
+       [SPOP_ERR_FRAMEID_NOTFOUND]   = IST("frame-id not found"),
+       [SPOP_ERR_RES]                = IST("resource allocation error"),
+       [SPOP_ERR_UNKNOWN]            = IST("an unknown error occurred"),
 };
 
 
@@ -1463,7 +1463,7 @@ static int spop_conn_send_hello(struct spop_conn *spop_conn)
  */
 static int spop_conn_send_disconnect(struct spop_conn *spop_conn)
 {
-       const char *reason;
+       struct ist reason;
        struct buffer outbuf;
        struct buffer *mbuf;
        char *p, *end;
@@ -1519,8 +1519,7 @@ static int spop_conn_send_disconnect(struct spop_conn *spop_conn)
        reason = spop_err_reasons[spop_conn->errcode];
 
        *p++ = SPOP_DATA_T_STR;
-       sz = strlen(reason);
-       if (spoe_encode_buffer(reason, sz, &p, end) == -1)
+       if (spoe_encode_buffer(istptr(reason), istlen(reason), &p, end) == -1)
                goto full;
 
        outbuf.data += p - b_tail(&outbuf);