MINOR: spoe: export the list of SPOP error reasons

The strings representing the human-readable version for SPOP errors are now
exported. It is now an array of IST to ease manipulation.
This commit is contained in:
Christopher Faulet 2024-07-22 18:57:00 +02:00
parent f8fed07d3a
commit 2f3c4d1b6c
2 changed files with 19 additions and 19 deletions

View File

@ -29,6 +29,7 @@
struct appctx; struct appctx;
extern const struct ist spop_err_reasons[SPOP_ERR_ENTRIES];
extern const struct spop_version spop_supported_versions[]; extern const struct spop_version spop_supported_versions[];
struct spoe_agent *spoe_appctx_agent(struct appctx *appctx); struct spoe_agent *spoe_appctx_agent(struct appctx *appctx);

View 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)); DECLARE_STATIC_POOL(pool_head_spop_strm, "spop_strm", sizeof(struct spop_strm));
const char *spop_err_reasons[SPOP_ERR_ENTRIES] = { const struct ist spop_err_reasons[SPOP_ERR_ENTRIES] = {
[SPOP_ERR_NONE] = "normal", [SPOP_ERR_NONE] = IST("normal"),
[SPOP_ERR_IO] = "I/O error", [SPOP_ERR_IO] = IST("I/O error"),
[SPOP_ERR_TOUT] = "a timeout occurred", [SPOP_ERR_TOUT] = IST("a timeout occurred"),
[SPOP_ERR_TOO_BIG] = "frame is too big", [SPOP_ERR_TOO_BIG] = IST("frame is too big"),
[SPOP_ERR_INVALID] = "invalid frame received", [SPOP_ERR_INVALID] = IST("invalid frame received"),
[SPOP_ERR_NO_VSN] = "version value not found", [SPOP_ERR_NO_VSN] = IST("version value not found"),
[SPOP_ERR_NO_FRAME_SIZE] = "max-frame-size value not found", [SPOP_ERR_NO_FRAME_SIZE] = IST("max-frame-size value not found"),
[SPOP_ERR_NO_CAP] = "capabilities value not found", [SPOP_ERR_NO_CAP] = IST("capabilities value not found"),
[SPOP_ERR_BAD_VSN] = "unsupported version", [SPOP_ERR_BAD_VSN] = IST("unsupported version"),
[SPOP_ERR_BAD_FRAME_SIZE] = "max-frame-size too big or too small", [SPOP_ERR_BAD_FRAME_SIZE] = IST("max-frame-size too big or too small"),
[SPOP_ERR_FRAG_NOT_SUPPORTED] = "fragmentation not supported", [SPOP_ERR_FRAG_NOT_SUPPORTED] = IST("fragmentation not supported"),
[SPOP_ERR_INTERLACED_FRAMES] = "invalid interlaced frames", [SPOP_ERR_INTERLACED_FRAMES] = IST("invalid interlaced frames"),
[SPOP_ERR_FRAMEID_NOTFOUND] = "frame-id not found", [SPOP_ERR_FRAMEID_NOTFOUND] = IST("frame-id not found"),
[SPOP_ERR_RES] = "resource allocation error", [SPOP_ERR_RES] = IST("resource allocation error"),
[SPOP_ERR_UNKNOWN] = "an unknown error occurred", [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) static int spop_conn_send_disconnect(struct spop_conn *spop_conn)
{ {
const char *reason; struct ist reason;
struct buffer outbuf; struct buffer outbuf;
struct buffer *mbuf; struct buffer *mbuf;
char *p, *end; 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]; reason = spop_err_reasons[spop_conn->errcode];
*p++ = SPOP_DATA_T_STR; *p++ = SPOP_DATA_T_STR;
sz = strlen(reason); if (spoe_encode_buffer(istptr(reason), istlen(reason), &p, end) == -1)
if (spoe_encode_buffer(reason, sz, &p, end) == -1)
goto full; goto full;
outbuf.data += p - b_tail(&outbuf); outbuf.data += p - b_tail(&outbuf);