From 21e9267ac3bd8642307b0f9791d3e46998141620 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 30 Aug 2017 10:30:04 +0200 Subject: [PATCH] MINOR: fd: Add fd_update_events function 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/proto/fd.h b/include/proto/fd.h index 14b284942..56e20827c 100644 --- a/include/proto/fd.h +++ b/include/proto/fd.h @@ -343,6 +343,20 @@ static inline void fd_want_send(int fd) } } +/* Update events seen for 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 for being polled */ static inline void fd_insert(int fd) { -- 2.47.3