mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-18 11:40:50 +00:00
MINOR: applet: define applet_putchk_stress() alternative
Previous patch introduced stress mode to be able to easily test alternative code paths. The first point would be to force interruption of stats dump on every line and check reentrant patchs, in particular while adding and removing servers instances. The purpose of this patch is to be able to use applet_putchk_stress() during stats dump while not impacting other applets. To support this, extract applet_putchk() into an internal _applet_putchk() which have a new argument stress. Define two helpers applet_putchk() and applet_putchk_stress(), the latter to set the stress argument to true. For the moment, applet_putchk_stress() is not used. This will be the subject of the next patch.
This commit is contained in:
parent
9d19fc4cf7
commit
1f458b3ea8
@ -279,16 +279,16 @@ static inline void applet_expect_data(struct appctx *appctx)
|
||||
se_fl_clr(appctx->sedesc, SE_FL_EXP_NO_DATA);
|
||||
}
|
||||
|
||||
/* writes chunk <chunk> into the input channel of the stream attached to this
|
||||
* appctx's endpoint, and marks the SC_FL_NEED_ROOM on a channel full error.
|
||||
* See ci_putchk() for the list of return codes.
|
||||
*/
|
||||
static inline int applet_putchk(struct appctx *appctx, struct buffer *chunk)
|
||||
/* Should only be used via wrappers applet_putchk() / applet_putchk_stress(). */
|
||||
static inline int _applet_putchk(struct appctx *appctx, struct buffer *chunk,
|
||||
int stress)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (appctx->flags & APPCTX_FL_INOUT_BUFS) {
|
||||
if (b_data(chunk) > b_room(&appctx->outbuf)) {
|
||||
if (unlikely(stress) ?
|
||||
b_data(&appctx->outbuf) :
|
||||
b_data(chunk) > b_room(&appctx->outbuf)) {
|
||||
applet_fl_set(appctx, APPCTX_FL_OUTBLK_FULL);
|
||||
ret = -1;
|
||||
}
|
||||
@ -300,8 +300,8 @@ static inline int applet_putchk(struct appctx *appctx, struct buffer *chunk)
|
||||
else {
|
||||
struct sedesc *se = appctx->sedesc;
|
||||
|
||||
ret = ci_putchk(sc_ic(se->sc), chunk);
|
||||
if (ret < 0) {
|
||||
if ((unlikely(stress) && ci_data(sc_ic(se->sc))) ||
|
||||
(ret = ci_putchk(sc_ic(se->sc), chunk)) < 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
|
||||
@ -311,9 +311,25 @@ static inline int applet_putchk(struct appctx *appctx, struct buffer *chunk)
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* writes chunk <chunk> into the input channel of the stream attached to this
|
||||
* appctx's endpoint, and marks the SC_FL_NEED_ROOM on a channel full error.
|
||||
* See ci_putchk() for the list of return codes.
|
||||
*/
|
||||
static inline int applet_putchk(struct appctx *appctx, struct buffer *chunk)
|
||||
{
|
||||
return _applet_putchk(appctx, chunk, 0);
|
||||
}
|
||||
|
||||
/* Equivalent of applet_putchk() but with stress condition alternatives activated. */
|
||||
static inline int applet_putchk_stress(struct appctx *appctx, struct buffer *chunk)
|
||||
{
|
||||
return _applet_putchk(appctx, chunk, 1);
|
||||
}
|
||||
|
||||
/* writes <len> chars from <blk> into the input channel of the stream attached
|
||||
* to this appctx's endpoint, and marks the SC_FL_NEED_ROOM on a channel full
|
||||
* error. See ci_putblk() for the list of return codes.
|
||||
|
Loading…
Reference in New Issue
Block a user