[MEDIUM] buffers: ensure buffer_shut* are properly called upon shutdowns
It is important that buffer states reflect the state of both sides so
that we can remove client and server state inter-dependencies.
diff --git a/include/proto/buffers.h b/include/proto/buffers.h
index c25e8f6..7a4e0b0 100644
--- a/include/proto/buffers.h
+++ b/include/proto/buffers.h
@@ -73,6 +73,13 @@
buf->flags |= BF_SHUTR_PENDING;
}
+/* marks the buffer as "shutdown done" for reads and cancels the timeout */
+static inline void buffer_shutr_done(struct buffer *buf)
+{
+ buf->rex = TICK_ETERNITY;
+ buf->flags |= BF_SHUTR_DONE;
+}
+
/* marks the buffer as "shutdown pending" for writes and cancels the timeout */
static inline void buffer_shutw(struct buffer *buf)
{
@@ -80,6 +87,13 @@
buf->flags |= BF_SHUTW_PENDING;
}
+/* marks the buffer as "shutdown done" for writes and cancels the timeout */
+static inline void buffer_shutw_done(struct buffer *buf)
+{
+ buf->wex = TICK_ETERNITY;
+ buf->flags |= BF_SHUTW_DONE;
+}
+
/* returns the maximum number of bytes writable at once in this buffer */
static inline int buffer_max(const struct buffer *buf)
diff --git a/include/types/buffers.h b/include/types/buffers.h
index a9de965..7539901 100644
--- a/include/types/buffers.h
+++ b/include/types/buffers.h
@@ -28,12 +28,12 @@
/* The BF_* macros designate Buffer Flags, which may be ORed in the bit field
* member 'flags' in struct buffer.
*/
-#define BF_SHUTR_PENDING 1
-#define BF_SHUTR_DONE 2
+#define BF_SHUTR_PENDING 1 /* ignored if BF_SHUTW_DONE */
+#define BF_SHUTR_DONE 2 /* takes precedence over BF_SHUTR_PENDING */
#define BF_SHUTR_STATUS (BF_SHUTR_PENDING|BF_SHUTR_DONE)
-#define BF_SHUTW_PENDING 4
-#define BF_SHUTW_DONE 8
+#define BF_SHUTW_PENDING 4 /* ignored if BF_SHUTW_DONE */
+#define BF_SHUTW_DONE 8 /* takes precedence over BF_SHUTW_PENDING */
#define BF_SHUTW_STATUS (BF_SHUTW_PENDING|BF_SHUTW_DONE)
#define BF_PARTIAL_READ 16