}
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 */
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,
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
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);
}
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*
*/
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 */
* 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))
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))
return appctx;
fail_task:
- sedesc_free(appctx->endp);
+ sedesc_free(appctx->sedesc);
fail_endp:
pool_free(pool_head_appctx, appctx);
fail_appctx:
/* 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;
}
/* 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;
}
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
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);
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.
*/
/* 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
/* 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;
}
}
break;
default: /* abnormal state */
- se_fl_set(appctx->endp, SE_FL_ERROR);
+ se_fl_set(appctx->sedesc, SE_FL_ERROR);
break;
}
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;
}
/* 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;
}
}
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;
}