]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: channel: make the channel be a const in all {ci,co}_get* functions
authorWilly Tarreau <w@1wt.eu>
Thu, 19 Oct 2017 12:58:40 +0000 (14:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Oct 2017 13:01:08 +0000 (15:01 +0200)
There's no point having the channel marked writable as these functions
only extract data from the channel. The code was retrieved from their
ci/co ancestors.

include/proto/channel.h
src/channel.c

index 51c6976382db67b90632cd46e33e9cfa78adf514..9e12b5efc41d1d7ca78155315dedacf7da497ca1 100644 (file)
@@ -48,13 +48,13 @@ unsigned long long __channel_forward(struct channel *chn, unsigned long long byt
 int ci_putblk(struct channel *chn, const char *str, int len);
 struct buffer *ci_swpbuf(struct channel *chn, struct buffer *buf);
 int ci_putchr(struct channel *chn, char c);
-int ci_getline_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
-int ci_getblk_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
+int ci_getline_nc(const struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
+int ci_getblk_nc(const struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
 int co_inject(struct channel *chn, const char *msg, int len);
-int co_getline(struct channel *chn, char *str, int len);
-int co_getblk(struct channel *chn, char *blk, int len, int offset);
-int co_getline_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
-int co_getblk_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
+int co_getline(const struct channel *chn, char *str, int len);
+int co_getblk(const struct channel *chn, char *blk, int len, int offset);
+int co_getline_nc(const struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
+int co_getblk_nc(const struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
 
 
 /* returns a pointer to the stream the channel belongs to */
@@ -139,7 +139,7 @@ static inline void channel_forward_forever(struct channel *chn)
  * jump-less and much more efficient on both 32 and 64-bit than
  * the boolean test.
  */
-static inline unsigned int channel_is_empty(struct channel *c)
+static inline unsigned int channel_is_empty(const struct channel *c)
 {
        return !(c->buf->o | (long)c->pipe);
 }
index 62b3ffb6c83013fc36004cc3e97a4c9a31689fa3..bd5c4de04f647d7fbbce053df8de0768b25f443e 100644 (file)
@@ -241,7 +241,7 @@ struct buffer *ci_swpbuf(struct channel *chn, struct buffer *buf)
  * output are full. If either of them is full, the string may be returned
  * as is, without the '\n'.
  */
-int co_getline(struct channel *chn, char *str, int len)
+int co_getline(const struct channel *chn, char *str, int len)
 {
        int ret, max;
        char *p;
@@ -290,7 +290,7 @@ int co_getline(struct channel *chn, char *str, int len)
  * The channel status is not changed. The caller must call co_skip() to
  * update it.
  */
-int co_getblk(struct channel *chn, char *blk, int len, int offset)
+int co_getblk(const struct channel *chn, char *blk, int len, int offset)
 {
        if (chn->flags & CF_SHUTW)
                return -1;
@@ -312,7 +312,7 @@ int co_getblk(struct channel *chn, char *blk, int len, int offset)
  * The channel status is not changed. The caller must call co_skip() to
  * update it. Unused buffers are left in an undefined state.
  */
-int co_getblk_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2)
+int co_getblk_nc(const struct channel *chn, char **blk1, int *len1, char **blk2, int *len2)
 {
        if (unlikely(chn->buf->o == 0)) {
                if (chn->flags & CF_SHUTW)
@@ -332,7 +332,7 @@ int co_getblk_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *
  * full. If either of them is full, the string may be returned as is, without
  * the '\n'. Unused buffers are left in an undefined state.
  */
-int co_getline_nc(struct channel *chn,
+int co_getline_nc(const struct channel *chn,
                   char **blk1, int *len1,
                   char **blk2, int *len2)
 {
@@ -376,7 +376,7 @@ int co_getline_nc(struct channel *chn,
  *   =0 : not enough data available.
  *   <0 : no more bytes readable because input is shut.
  */
-int ci_getblk_nc(struct channel *chn,
+int ci_getblk_nc(const struct channel *chn,
                  char **blk1, int *len1,
                  char **blk2, int *len2)
 {
@@ -408,7 +408,7 @@ int ci_getblk_nc(struct channel *chn,
  * full. If either of them is full, the string may be returned as is, without
  * the '\n'. Unused buffers are left in an undefined state.
  */
-int ci_getline_nc(struct channel *chn,
+int ci_getline_nc(const struct channel *chn,
                   char **blk1, int *len1,
                   char **blk2, int *len2)
 {