From 40aa87a28f6e5f26a9021908689b69016230c596 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 18 Apr 2024 08:42:27 +0200 Subject: [PATCH] BUG/MEDIUM: applet: Fix applet API to put input data in a buffer applet_putblk and co were added to simplify applets. In 2.8, a fix was pushed to deal with all errors as a room error because the vast majority of applets didn't expect other kind of errors. The API was changed with the commit 389b7d1f7b ("BUG/MEDIUM: applet: Fix API for function to push new data in channels buffer"). Unfortunately and for unknown reason, the fix was totally failed. Checks on channel functions were just wrong and not consistent. applet_putblk() function is especially affected because the error is returned but no flag are set on the SC to request more room. Because of this bug, applets relying on it may be blocked, waiting for more room, and never woken up. It is an issue for the peer and spoe applets. This patch must be backported as far as 2.8. --- include/haproxy/applet.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index b76c027e9..8d9f49aec 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -325,7 +325,7 @@ static inline int applet_putblk(struct appctx *appctx, const char *blk, int len) struct sedesc *se = appctx->sedesc; ret = ci_putblk(sc_ic(se->sc), blk, len); - if (ret < -1) { + if (ret < 0) { /* XXX: Handle all errors as a lack of space because callers * don't handles other cases for now. So applets must be * careful to handles shutdown (-2) and invalid calls (-3) by @@ -362,7 +362,7 @@ static inline int applet_putstr(struct appctx *appctx, const char *str) struct sedesc *se = appctx->sedesc; ret = ci_putstr(sc_ic(se->sc), str); - if (ret == -1) { + if (ret < 0) { /* XXX: Handle all errors as a lack of space because callers * don't handles other cases for now. So applets must be * careful to handles shutdown (-2) and invalid calls (-3) by @@ -397,7 +397,7 @@ static inline int applet_putchr(struct appctx *appctx, char chr) struct sedesc *se = appctx->sedesc; ret = ci_putchr(sc_ic(se->sc), chr); - if (ret == -1) { + if (ret < 0) { /* XXX: Handle all errors as a lack of space because callers * don't handles other cases for now. So applets must be * careful to handles shutdown (-2) and invalid calls (-3) by