mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-02-09 19:31:06 +01:00
MINOR: channel: make use of bo_getblk{,_nc} for their channel equivalents
Let's reuse the buffer-level functions to perform the operations.
This commit is contained in:
parent
e0e734ccc5
commit
6b3f353bcf
@ -292,8 +292,6 @@ int co_getline(struct channel *chn, char *str, int len)
|
||||
*/
|
||||
int co_getblk(struct channel *chn, char *blk, int len, int offset)
|
||||
{
|
||||
int firstblock;
|
||||
|
||||
if (chn->flags & CF_SHUTW)
|
||||
return -1;
|
||||
|
||||
@ -303,20 +301,7 @@ int co_getblk(struct channel *chn, char *blk, int len, int offset)
|
||||
return 0;
|
||||
}
|
||||
|
||||
firstblock = chn->buf->data + chn->buf->size - bo_ptr(chn->buf);
|
||||
if (firstblock > offset) {
|
||||
if (firstblock >= len + offset) {
|
||||
memcpy(blk, bo_ptr(chn->buf) + offset, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
memcpy(blk, bo_ptr(chn->buf) + offset, firstblock - offset);
|
||||
memcpy(blk + firstblock - offset, chn->buf->data, len - firstblock + offset);
|
||||
return len;
|
||||
}
|
||||
|
||||
memcpy(blk, chn->buf->data + offset - firstblock, len);
|
||||
return len;
|
||||
return bo_getblk(chn->buf, blk, len, offset);
|
||||
}
|
||||
|
||||
/* Gets one or two blocks of data at once from a channel's output buffer.
|
||||
@ -335,17 +320,7 @@ int co_getblk_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (unlikely(chn->buf->p - chn->buf->o < chn->buf->data)) {
|
||||
*blk1 = chn->buf->p - chn->buf->o + chn->buf->size;
|
||||
*len1 = chn->buf->data + chn->buf->size - *blk1;
|
||||
*blk2 = chn->buf->data;
|
||||
*len2 = chn->buf->p - chn->buf->data;
|
||||
return 2;
|
||||
}
|
||||
|
||||
*blk1 = chn->buf->p - chn->buf->o;
|
||||
*len1 = chn->buf->o;
|
||||
return 1;
|
||||
return bo_getblk_nc(chn->buf, blk1, len1, blk2, len2);
|
||||
}
|
||||
|
||||
/* Gets one text line out of a channel's output buffer from a stream interface.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user