MINOR: fd: Add fd_update_events function
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 30 Aug 2017 08:30:04 +0000 (10:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 5 Sep 2017 13:43:09 +0000 (15:43 +0200)
This function should be called by the poller to set FD_POLL_* flags on an FD and
update its state if needed. This function has been added to ease threads support
integration.

include/proto/fd.h

index 14b2849..56e2082 100644 (file)
@@ -343,6 +343,20 @@ static inline void fd_want_send(int fd)
        }
 }
 
+/* Update events seen for FD <fd> and its state if needed. This should be called
+ * by the poller to set FD_POLL_* flags. */
+static inline void fd_update_events(int fd, int evts)
+{
+       fdtab[fd].ev &= FD_POLL_STICKY;
+       fdtab[fd].ev |= evts;
+
+       if (fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
+               fd_may_recv(fd);
+
+       if (fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR))
+               fd_may_send(fd);
+}
+
 /* Prepares <fd> for being polled */
 static inline void fd_insert(int fd)
 {