mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-22 14:49:45 -04:00
MEDIUM: cache: Use the sedesc to report and detect end of processing
We now try, as far as possible, to rely on the SE descriptor to detect end of processing. Idea is to no longer rely on the channel or the SC to do so. First, we now set SE_FL_EOS instead of calling and cf_shutr() to report the end of the stream. It happens when the response is fully sent (SE_FL_EOI is already set in this case) or when an error is reported. In this last case, SE_FL_ERROR is also set. Thanks to this change, it is now possible to detect the applet must only consume the request waiting for the upper layer releases it. So, if SE_FL_EOS or SE_FL_ERROR are set, it means the reponse was fully handled. And if SE_FL_SHR or SE_FL_SHW are set, it means the applet was released by upper layer and is waiting to be freed.
This commit is contained in:
parent
0ffc9d7be3
commit
f8130b2de2
1 changed files with 4 additions and 6 deletions
10
src/cache.c
10
src/cache.c
|
|
@ -1466,7 +1466,7 @@ static void http_cache_io_handler(struct appctx *appctx)
|
|||
res_htx = htx_from_buf(&res->buf);
|
||||
total = res_htx->data;
|
||||
|
||||
if (unlikely(sc->state == SC_ST_DIS || sc->state == SC_ST_CLO))
|
||||
if (unlikely(se_fl_test(appctx->sedesc, (SE_FL_EOS|SE_FL_ERROR|SE_FL_SHR|SE_FL_SHW))))
|
||||
goto out;
|
||||
|
||||
/* Check if the input buffer is available. */
|
||||
|
|
@ -1475,9 +1475,6 @@ static void http_cache_io_handler(struct appctx *appctx)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (res->flags & (CF_SHUTW|CF_SHUTR|CF_SHUTW_NOW))
|
||||
appctx->st0 = HTX_CACHE_END;
|
||||
|
||||
if (appctx->st0 == HTX_CACHE_INIT) {
|
||||
ctx->next = block_ptr(cache_ptr);
|
||||
ctx->offset = sizeof(*cache_ptr);
|
||||
|
|
@ -1531,8 +1528,8 @@ static void http_cache_io_handler(struct appctx *appctx)
|
|||
}
|
||||
|
||||
end:
|
||||
if (!(res->flags & CF_SHUTR) && appctx->st0 == HTX_CACHE_END)
|
||||
sc_shutr(sc);
|
||||
if (appctx->st0 == HTX_CACHE_END)
|
||||
se_fl_set(appctx->sedesc, SE_FL_EOS);
|
||||
|
||||
out:
|
||||
total = res_htx->data - total;
|
||||
|
|
@ -1557,6 +1554,7 @@ static void http_cache_io_handler(struct appctx *appctx)
|
|||
res_htx = htx_from_buf(&res->buf);
|
||||
|
||||
total = 0;
|
||||
se_fl_set(appctx->sedesc, SE_FL_ERROR);
|
||||
appctx->st0 = HTX_CACHE_END;
|
||||
goto end;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue