]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: conn_stream: test the various ops functions before calling them
authorWilly Tarreau <w@1wt.eu>
Tue, 24 May 2022 06:17:58 +0000 (08:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 27 May 2022 17:33:34 +0000 (19:33 +0200)
We currently call all ->shutr, ->chk_snd etc from ->ops unconditionally,
while the ->wake() call from data_cb is checked. Better check ops as
well for consistency, this will help get them merged.

include/haproxy/cs_utils.h

index ad8dba7c4d982209c9bc19aa2bbad1e4e3cd9a41..8534f10d8ca779096fb2d33a3eef2316c652d773 100644 (file)
@@ -275,13 +275,15 @@ static inline void cs_must_kill_conn(struct stconn *cs)
 /* Sends a shutr to the endpoint using the data layer */
 static inline void cs_shutr(struct stconn *cs)
 {
-       cs->ops->shutr(cs);
+       if (likely(cs->ops->shutr))
+               cs->ops->shutr(cs);
 }
 
 /* Sends a shutw to the endpoint using the data layer */
 static inline void cs_shutw(struct stconn *cs)
 {
-       cs->ops->shutw(cs);
+       if (likely(cs->ops->shutw))
+               cs->ops->shutw(cs);
 }
 
 /* This is to be used after making some room available in a channel. It will
@@ -302,13 +304,15 @@ static inline void cs_chk_rcv(struct stconn *cs)
                return;
 
        sc_ep_set(cs, SE_FL_RX_WAIT_EP);
-       cs->ops->chk_rcv(cs);
+       if (likely(cs->ops->chk_rcv))
+               cs->ops->chk_rcv(cs);
 }
 
 /* Calls chk_snd on the endpoint using the data layer */
 static inline void cs_chk_snd(struct stconn *cs)
 {
-       cs->ops->chk_snd(cs);
+       if (likely(cs->ops->chk_snd))
+               cs->ops->chk_snd(cs);
 }
 
 /* Combines both cs_update_rx() and cs_update_tx() at once */