]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] add buffer_check_timeouts() to check what timeouts have fired.
authorWilly Tarreau <w@1wt.eu>
Thu, 4 Sep 2008 07:14:08 +0000 (09:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 2 Nov 2008 09:19:10 +0000 (10:19 +0100)
This new function sets the BF_*_TIMEOUT flags when a buffer timeout
has expired.

include/proto/buffers.h

index e5df177c0e1592ffe17c6946c7a3687e6129b424..73999cea8215f0fe5b4a6326ac362e93a813c43d 100644 (file)
@@ -64,6 +64,24 @@ static inline int buffer_isfull(const struct buffer *buf) {
        return buf->l == BUFSIZE;
 }
 
+/* Check buffer timeouts, and set the corresponding flags. The
+ * likely/unlikely have been optimized for fastest normal path.
+ */
+static inline void buffer_check_timeouts(struct buffer *b)
+{
+       if (likely(!(b->flags & (BF_SHUTR|BF_READ_TIMEOUT))) &&
+           unlikely(tick_is_expired(b->rex, now_ms)))
+               b->flags |= BF_READ_TIMEOUT;
+
+       if (likely(!(b->flags & (BF_SHUTW|BF_WRITE_TIMEOUT))) &&
+           unlikely(tick_is_expired(b->wex, now_ms)))
+               b->flags |= BF_WRITE_TIMEOUT;
+
+       if (likely(!(b->flags & BF_ANA_TIMEOUT)) &&
+           unlikely(tick_is_expired(b->analyse_exp, now_ms)))
+               b->flags |= BF_ANA_TIMEOUT;
+}
+
 /* flushes any content from buffer <buf> and adjusts flags
  * accordingly.
  */