]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: fd: add two new calls fd_cond_{recv,send}()
authorWilly Tarreau <w@1wt.eu>
Thu, 5 Sep 2019 14:39:21 +0000 (16:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 Sep 2019 15:50:36 +0000 (17:50 +0200)
These two functions are used to enable recv/send but only if the FD is
not marked as active yet. The purpose is to conditionally mark them as
tentatively usable without interfering with the polling if polling was
already enabled, when it's supposed to be likely true.

include/proto/fd.h

index 747b34f78e2cd14a31ff1e0a168246d7a3326eef..e3b0b2b2f74f4d1e913231be23a77eb55676a602 100644 (file)
@@ -241,6 +241,26 @@ static inline void fd_may_recv(const int fd)
                return;
 }
 
+/* Report that FD <fd> may receive again without polling but only if its not
+ * active yet. This is in order to speculatively try to enable I/Os when it's
+ * highly likely that these will succeed, but without interfering with polling.
+ */
+static inline void fd_cond_recv(const int fd)
+{
+       if ((fdtab[fd].state & (FD_EV_ACTIVE_R|FD_EV_READY_R)) == 0)
+               HA_ATOMIC_BTS(&fdtab[fd].state, FD_EV_READY_R_BIT);
+}
+
+/* Report that FD <fd> may send again without polling but only if its not
+ * active yet. This is in order to speculatively try to enable I/Os when it's
+ * highly likely that these will succeed, but without interfering with polling.
+ */
+static inline void fd_cond_send(const int fd)
+{
+       if ((fdtab[fd].state & (FD_EV_ACTIVE_W|FD_EV_READY_W)) == 0)
+               HA_ATOMIC_BTS(&fdtab[fd].state, FD_EV_READY_W_BIT);
+}
+
 /* Report that FD <fd> may receive and send without polling. Used at FD
  * initialization.
  */