CLEANUP: applet: rename the sedesc pointer from "endp" to "sedesc"

Now at least it makes it obvious that it's the stream endpoint descriptor
and not an endpoint. There were few changes thanks to the previous refactor
of the flags.
This commit is contained in:
Willy Tarreau 2022-05-17 18:05:31 +02:00
parent ea59b0201c
commit d869e13ed8
9 changed files with 38 additions and 39 deletions

View File

@ -1564,7 +1564,7 @@ static void promex_appctx_handle_io(struct appctx *appctx)
}
res_htx->flags |= HTX_FL_EOM;
res->flags |= CF_EOI;
se_fl_set(appctx->endp, SE_FL_EOI);
se_fl_set(appctx->sedesc, SE_FL_EOI);
appctx->st0 = PROMEX_ST_END;
/* fall through */

View File

@ -63,7 +63,7 @@ struct appctx {
struct buffer *chunk; /* used to store unfinished commands */
struct applet *applet; /* applet this context refers to */
struct session *sess; /* session for frontend applets (NULL for backend applets) */
struct sedesc *endp;
struct sedesc *sedesc; /* stream endpoint descriptor the applet is attached to */
struct act_rule *rule; /* rule associated with the applet. */
int (*io_handler)(struct appctx *appctx); /* used within the cli_io_handler when st0 = CLI_ST_CALLBACK */
void (*io_release)(struct appctx *appctx); /* used within the cli_io_handler when st0 = CLI_ST_CALLBACK,

View File

@ -40,23 +40,23 @@ int appctx_buf_available(void *arg);
void *applet_reserve_svcctx(struct appctx *appctx, size_t size);
void appctx_shut(struct appctx *appctx);
struct appctx *appctx_new(struct applet *applet, struct sedesc *endp, unsigned long thread_mask);
struct appctx *appctx_new(struct applet *applet, struct sedesc *sedesc, unsigned long thread_mask);
int appctx_finalize_startup(struct appctx *appctx, struct proxy *px, struct buffer *input);
void appctx_free_on_early_error(struct appctx *appctx);
static inline struct appctx *appctx_new_on(struct applet *applet, struct sedesc *endp, uint thr)
static inline struct appctx *appctx_new_on(struct applet *applet, struct sedesc *sedesc, uint thr)
{
return appctx_new(applet, endp, 1UL << thr);
return appctx_new(applet, sedesc, 1UL << thr);
}
static inline struct appctx *appctx_new_here(struct applet *applet, struct sedesc *endp)
static inline struct appctx *appctx_new_here(struct applet *applet, struct sedesc *sedesc)
{
return appctx_new(applet, endp, tid_bit);
return appctx_new(applet, sedesc, tid_bit);
}
static inline struct appctx *appctx_new_anywhere(struct applet *applet, struct sedesc *endp)
static inline struct appctx *appctx_new_anywhere(struct applet *applet, struct sedesc *sedesc)
{
return appctx_new(applet, endp, MAX_THREADS_MASK);
return appctx_new(applet, sedesc, MAX_THREADS_MASK);
}
/* Helper function to call .init applet callback function, if it exists. Returns 0
@ -84,8 +84,8 @@ static inline void __appctx_free(struct appctx *appctx)
LIST_DEL_INIT(&appctx->buffer_wait.list);
if (appctx->sess)
session_free(appctx->sess);
BUG_ON(appctx->endp && !se_fl_test(appctx->endp, SE_FL_ORPHAN));
sedesc_free(appctx->endp);
BUG_ON(appctx->sedesc && !se_fl_test(appctx->sedesc, SE_FL_ORPHAN));
sedesc_free(appctx->sedesc);
pool_free(pool_head_appctx, appctx);
_HA_ATOMIC_DEC(&nb_applets);
}
@ -112,10 +112,10 @@ static inline void appctx_wakeup(struct appctx *appctx)
task_wakeup(appctx->t, TASK_WOKEN_OTHER);
}
/* returns the conn_stream the appctx is attached to, via the endp */
/* returns the conn_stream the appctx is attached to, via the sedesc */
static inline struct conn_stream *appctx_cs(const struct appctx *appctx)
{
return appctx->endp->cs;
return appctx->sedesc->cs;
}
/* returns the stream the appctx is attached to. Note that a stream *must*
@ -123,7 +123,7 @@ static inline struct conn_stream *appctx_cs(const struct appctx *appctx)
*/
static inline struct stream *appctx_strm(const struct appctx *appctx)
{
return __cs_strm(appctx->endp->cs);
return __cs_strm(appctx->sedesc->cs);
}
#endif /* _HAPROXY_APPLET_H */

View File

@ -31,12 +31,12 @@ DECLARE_POOL(pool_head_appctx, "appctx", sizeof(struct appctx));
* appctx_free(). <applet> is assigned as the applet, but it can be NULL. The
* applet's task is always created on the current thread.
*/
struct appctx *appctx_new(struct applet *applet, struct sedesc *endp, unsigned long thread_mask)
struct appctx *appctx_new(struct applet *applet, struct sedesc *sedesc, unsigned long thread_mask)
{
struct appctx *appctx;
/* Backend appctx cannot be started on another thread than the local one */
BUG_ON(thread_mask != tid_bit && endp);
BUG_ON(thread_mask != tid_bit && sedesc);
appctx = pool_zalloc(pool_head_appctx);
if (unlikely(!appctx))
@ -46,14 +46,14 @@ struct appctx *appctx_new(struct applet *applet, struct sedesc *endp, unsigned l
appctx->obj_type = OBJ_TYPE_APPCTX;
appctx->applet = applet;
appctx->sess = NULL;
if (!endp) {
endp = sedesc_new();
if (!endp)
if (!sedesc) {
sedesc = sedesc_new();
if (!sedesc)
goto fail_endp;
endp->se = appctx;
se_fl_set(endp, SE_FL_T_APPLET | SE_FL_ORPHAN);
sedesc->se = appctx;
se_fl_set(sedesc, SE_FL_T_APPLET | SE_FL_ORPHAN);
}
appctx->endp = endp;
appctx->sedesc = sedesc;
appctx->t = task_new(thread_mask);
if (unlikely(!appctx->t))
@ -69,7 +69,7 @@ struct appctx *appctx_new(struct applet *applet, struct sedesc *endp, unsigned l
return appctx;
fail_task:
sedesc_free(appctx->endp);
sedesc_free(appctx->sedesc);
fail_endp:
pool_free(pool_head_appctx, appctx);
fail_appctx:
@ -93,12 +93,12 @@ int appctx_finalize_startup(struct appctx *appctx, struct proxy *px, struct buff
/* async startup is only possible for frontend appctx. Thus for orphan
* appctx. Because no backend appctx can be orphan.
*/
BUG_ON(!se_fl_test(appctx->endp, SE_FL_ORPHAN));
BUG_ON(!se_fl_test(appctx->sedesc, SE_FL_ORPHAN));
sess = session_new(px, NULL, &appctx->obj_type);
if (!sess)
return -1;
if (!cs_new_from_endp(appctx->endp, sess, input)) {
if (!cs_new_from_endp(appctx->sedesc, sess, input)) {
session_free(sess);
return -1;
}
@ -114,7 +114,7 @@ void appctx_free_on_early_error(struct appctx *appctx)
/* If a frontend apctx is attached to a conn-stream, release the stream
* instead of the appctx.
*/
if (!se_fl_test(appctx->endp, SE_FL_ORPHAN) && !(appctx_cs(appctx)->flags & CS_FL_ISBACK)) {
if (!se_fl_test(appctx->sedesc, SE_FL_ORPHAN) && !(appctx_cs(appctx)->flags & CS_FL_ISBACK)) {
stream_free(appctx_strm(appctx));
return;
}
@ -140,18 +140,18 @@ void *applet_reserve_svcctx(struct appctx *appctx, size_t size)
return appctx->svcctx;
}
/* call the applet's release() function if any, and marks the endp as shut.
/* call the applet's release() function if any, and marks the sedesc as shut.
* Needs to be called upon close().
*/
void appctx_shut(struct appctx *appctx)
{
if (se_fl_test(appctx->endp, SE_FL_SHR | SE_FL_SHW))
if (se_fl_test(appctx->sedesc, SE_FL_SHR | SE_FL_SHW))
return;
if (appctx->applet->release)
appctx->applet->release(appctx);
se_fl_set(appctx->endp, SE_FL_SHRR | SE_FL_SHWN);
se_fl_set(appctx->sedesc, SE_FL_SHRR | SE_FL_SHWN);
}
/* Callback used to wake up an applet when a buffer is available. The applet
@ -167,7 +167,7 @@ int appctx_buf_available(void *arg)
struct conn_stream *cs = appctx_cs(appctx);
/* allocation requested ? */
if (!se_fl_test(appctx->endp, SE_FL_RXBLK_BUFF))
if (!se_fl_test(appctx->sedesc, SE_FL_RXBLK_BUFF))
return 0;
cs_rx_buff_rdy(cs);
@ -199,7 +199,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
return NULL;
}
if (se_fl_test(app->endp, SE_FL_ORPHAN)) {
if (se_fl_test(app->sedesc, SE_FL_ORPHAN)) {
/* Finalize init of orphan appctx. .init callback function must
* be defined and it must finalize appctx startup.
*/
@ -244,8 +244,8 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
/* measure the call rate and check for anomalies when too high */
rate = update_freq_ctr(&app->call_rate, 1);
if (rate >= 100000 && app->call_rate.prev_ctr && // looped more than 100k times over last second
((b_size(cs_ib(cs)) && se_fl_test(app->endp, SE_FL_RXBLK_BUFF)) || // asks for a buffer which is present
(b_size(cs_ib(cs)) && !b_data(cs_ib(cs)) && se_fl_test(app->endp, SE_FL_RXBLK_ROOM)) || // asks for room in an empty buffer
((b_size(cs_ib(cs)) && se_fl_test(app->sedesc, SE_FL_RXBLK_BUFF)) || // asks for a buffer which is present
(b_size(cs_ib(cs)) && !b_data(cs_ib(cs)) && se_fl_test(app->sedesc, SE_FL_RXBLK_ROOM)) || // asks for room in an empty buffer
(b_data(cs_ob(cs)) && cs_tx_endp_ready(cs) && !cs_tx_blocked(cs)) || // asks for data already present
(!b_data(cs_ib(cs)) && b_data(cs_ob(cs)) && // didn't return anything ...
(cs_oc(cs)->flags & (CF_WRITE_PARTIAL|CF_SHUTW_NOW)) == CF_SHUTW_NOW))) { // ... and left data pending after a shut

View File

@ -1527,7 +1527,7 @@ static void http_cache_io_handler(struct appctx *appctx)
/* no more data are expected. */
res_htx->flags |= HTX_FL_EOM;
res->flags |= CF_EOI;
se_fl_set(appctx->endp, SE_FL_EOI);
se_fl_set(appctx->sedesc, SE_FL_EOI);
appctx->st0 = HTX_CACHE_END;
}

View File

@ -1108,7 +1108,7 @@ static void cli_io_handler(struct appctx *appctx)
}
break;
default: /* abnormal state */
se_fl_set(appctx->endp, SE_FL_ERROR);
se_fl_set(appctx->sedesc, SE_FL_ERROR);
break;
}

View File

@ -9615,7 +9615,7 @@ void hlua_applet_http_fct(struct appctx *ctx)
res_htx->flags |= HTX_FL_EOM;
res->flags |= CF_EOI;
se_fl_set(ctx->endp, SE_FL_EOI);
se_fl_set(ctx->sedesc, SE_FL_EOI);
strm->txn->status = http_ctx->status;
http_ctx->flags |= APPLET_RSP_SENT;
}

View File

@ -732,8 +732,7 @@ static void httpclient_applet_io_handler(struct appctx *appctx)
/* if the request contains the HTX_FL_EOM, we finished the request part. */
if (htx->flags & HTX_FL_EOM) {
req->flags |= CF_EOI;
se_fl_set(appctx->endp,
SE_FL_EOI);
se_fl_set(appctx->sedesc, SE_FL_EOI);
appctx->st0 = HTTPCLIENT_S_RES_STLINE;
}

View File

@ -4349,7 +4349,7 @@ static void http_stats_io_handler(struct appctx *appctx)
}
res_htx->flags |= HTX_FL_EOM;
res->flags |= CF_EOI;
se_fl_set(appctx->endp, SE_FL_EOI);
se_fl_set(appctx->sedesc, SE_FL_EOI);
appctx->st0 = STAT_HTTP_END;
}