]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: applet: rename the sedesc pointer from "endp" to "sedesc"
authorWilly Tarreau <w@1wt.eu>
Tue, 17 May 2022 16:05:31 +0000 (18:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 27 May 2022 17:33:34 +0000 (19:33 +0200)
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.

addons/promex/service-prometheus.c
include/haproxy/applet-t.h
include/haproxy/applet.h
src/applet.c
src/cache.c
src/cli.c
src/hlua.c
src/http_client.c
src/stats.c

index 8274de228bd74194b45f863557f4f5422c310df2..6471dae1d00b7f923660306f1d3f0f9045d27a2b 100644 (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 */
 
index ca0e2c2b77c3516070a63c4a45bfda0449673e96..e528452faf8858343890b5a23336ab7487d36b0f 100644 (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,
index 7cc97426dab5e62c1f00c1471489c621c42a78f3..3c80adba7ff495cd8323fffa5dc406c695db8f3c 100644 (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 */
index b4c9bef32dc341ff3f02834cae0508fd89c402d2..8d45ac1c37ca0ac02d4012dbef713190b7f16cc3 100644 (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
index 4f52d7298cb3bb7093a7aadce814a30ec6517e89..8b36b2e4b17633e7f17e33ea16cbd99d09972650 100644 (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;
        }
 
index f9a0a4f2b37c9d7aac293f1133bee551a0185ca5..9d17df97a9b6b52ee7a1372865e92b85dd35cf16 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -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;
                        }
 
index 8ba4fbf79321bbfc1eed7625077ebfc3ea718f9d..47bfe90e2013066b54d34d6a124373344cdfa0fd 100644 (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;
        }
index 67427d5de5568051a0577fb7e593413b6aa5fe2e..9fb942f49149ae5d9e34f27fd91151456f9b8545 100644 (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;
                                        }
 
index 24207aec6062ca40bbb600b08409761525b1e7e0..2a4dc136ba2f852a30e291ea5c2586b4c22f0b21 100644 (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;
        }