]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: channel/htx: Add function to skips output bytes from an HTX channel
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 25 Feb 2019 09:44:51 +0000 (10:44 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 26 Feb 2019 13:04:23 +0000 (14:04 +0100)
It is the HTX version of co_skip(). Internally, It uses the function htx_drain().

It will be used by other commits to fix bugs, so it must be backported to 1.9.

include/proto/channel.h

index 017c5d1798374d3aa75176a129bf0b8d9ac3fb4f..a33262e21f3cede76beae0d59c556918f24348a7 100644 (file)
@@ -922,6 +922,23 @@ static inline void co_skip(struct channel *chn, int len)
        chn->flags |= CF_WRITE_PARTIAL | CF_WROTE_DATA;
 }
 
+/* HTX version of co_skip(). This function skips at most <len> bytes from the
+ * output of the channel <chn>. Depending on how data are stored in <htx> less
+ * than <len> bytes can be skipped. Channel flags WRITE_PARTIAL and WROTE_DATA
+ * are set.
+ */
+static inline void co_htx_skip(struct channel *chn, struct htx *htx, int len)
+{
+       struct htx_ret htxret;
+
+       htxret = htx_drain(htx, len);
+       if (htxret.ret) {
+               chn->output -= htxret.ret;
+
+               /* notify that some data was written to the SI from the buffer */
+               chn->flags |= CF_WRITE_PARTIAL | CF_WROTE_DATA;
+       }
+}
 
 /* Tries to copy chunk <chunk> into the channel's buffer after length controls.
  * The chn->o and to_forward pointers are updated. If the channel's input is