]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int: make it clear that si_ops cannot be null
authorWilly Tarreau <w@1wt.eu>
Wed, 7 Nov 2018 10:28:12 +0000 (11:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Nov 2018 09:18:37 +0000 (10:18 +0100)
There was an ambiguity in which functions of the si_ops struct could be
null or not. only ->update doesn't exist in one of the si_ops (the
embedded one), all others are always defined. ->shutr and ->shutw were
never tested. However ->chk_rcv() and ->chk_snd() were tested, causing
confusion about the proper way to wake the other side up if undefined
(which never happens).

Let's update the comments to state these functions are mandatory and
remove the offending checks.

include/proto/stream_interface.h
include/types/stream_interface.h

index c2c5310dcbaad9ce87d481a7c3b42381a7a93bfd..7bab7ffd043199d1f8dbf894c21bd65290b0d37f 100644 (file)
@@ -388,15 +388,13 @@ static inline void si_update(struct stream_interface *si)
 /* Calls chk_rcv on the connection using the data layer */
 static inline void si_chk_rcv(struct stream_interface *si)
 {
-       if (si->ops->chk_rcv)
-               si->ops->chk_rcv(si);
+       si->ops->chk_rcv(si);
 }
 
 /* Calls chk_snd on the connection using the data layer */
 static inline void si_chk_snd(struct stream_interface *si)
 {
-       if (si->ops->chk_snd)
-               si->ops->chk_snd(si);
+       si->ops->chk_snd(si);
 }
 
 /* Calls chk_snd on the connection using the ctrl layer */
index 3a9895e60f25ba70a3c314124ff0159036f1e935..0362afdf58ab3d5e436ed5addbc3b47506ac1232 100644 (file)
@@ -106,11 +106,11 @@ struct stream_interface {
 
 /* operations available on a stream-interface */
 struct si_ops {
-       void (*update)(struct stream_interface *);  /* I/O update function */
-       void (*chk_rcv)(struct stream_interface *); /* chk_rcv function */
-       void (*chk_snd)(struct stream_interface *); /* chk_snd function */
-       void (*shutr)(struct stream_interface *);   /* shut read function */
-       void (*shutw)(struct stream_interface *);   /* shut write function */
+       void (*update)(struct stream_interface *);  /* I/O update function, may be null */
+       void (*chk_rcv)(struct stream_interface *); /* chk_rcv function, may not be null */
+       void (*chk_snd)(struct stream_interface *); /* chk_snd function, may not be null */
+       void (*shutr)(struct stream_interface *);   /* shut read function, may not be null */
+       void (*shutw)(struct stream_interface *);   /* shut write function, may not be null */
 };
 
 #endif /* _TYPES_STREAM_INTERFACE_H */