mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
REORG: channel: finally rename the last bi_* / bo_* functions
For HTTP/2 we'll need some buffer-only equivalent functions to some of the ones applying to channels and still squatting the bi_* / bo_* namespace. Since these names have kept being misleading for quite some time now and are really getting annoying, it's time to rename them. This commit will use "ci/co" as the prefix (for "channel in", "channel out") instead of "bi/bo". The following ones were renamed : bi_getblk_nc, bi_getline_nc, bi_putblk, bi_putchr, bo_getblk, bo_getblk_nc, bo_getline, bo_getline_nc, bo_inject, bi_putchk, bi_putstr, bo_getchr, bo_skip, bi_swpbuf
This commit is contained in:
parent
5b9834f12a
commit
06d80a9a9c
@ -45,16 +45,16 @@ int init_channel();
|
||||
unsigned long long __channel_forward(struct channel *chn, unsigned long long bytes);
|
||||
|
||||
/* SI-to-channel functions working with buffers */
|
||||
int bi_putblk(struct channel *chn, const char *str, int len);
|
||||
struct buffer *bi_swpbuf(struct channel *chn, struct buffer *buf);
|
||||
int bi_putchr(struct channel *chn, char c);
|
||||
int bi_getline_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
|
||||
int bi_getblk_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
|
||||
int bo_inject(struct channel *chn, const char *msg, int len);
|
||||
int bo_getline(struct channel *chn, char *str, int len);
|
||||
int bo_getblk(struct channel *chn, char *blk, int len, int offset);
|
||||
int bo_getline_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
|
||||
int bo_getblk_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
|
||||
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 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);
|
||||
|
||||
|
||||
/* returns a pointer to the stream the channel belongs to */
|
||||
@ -479,7 +479,7 @@ static inline void channel_truncate(struct channel *chn)
|
||||
* the caller's responsibility to ensure that <len> is never larger than
|
||||
* chn->o. Channel flag WRITE_PARTIAL is set.
|
||||
*/
|
||||
static inline void bo_skip(struct channel *chn, int len)
|
||||
static inline void co_skip(struct channel *chn, int len)
|
||||
{
|
||||
chn->buf->o -= len;
|
||||
|
||||
@ -498,11 +498,11 @@ static inline void bo_skip(struct channel *chn, int len)
|
||||
* Channel flag READ_PARTIAL is updated if some data can be transferred. The
|
||||
* chunk's length is updated with the number of bytes sent.
|
||||
*/
|
||||
static inline int bi_putchk(struct channel *chn, struct chunk *chunk)
|
||||
static inline int ci_putchk(struct channel *chn, struct chunk *chunk)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = bi_putblk(chn, chunk->str, chunk->len);
|
||||
ret = ci_putblk(chn, chunk->str, chunk->len);
|
||||
if (ret > 0)
|
||||
chunk->len -= ret;
|
||||
return ret;
|
||||
@ -516,19 +516,19 @@ static inline int bi_putchk(struct channel *chn, struct chunk *chunk)
|
||||
* number). Channel flag READ_PARTIAL is updated if some data can be
|
||||
* transferred.
|
||||
*/
|
||||
static inline int bi_putstr(struct channel *chn, const char *str)
|
||||
static inline int ci_putstr(struct channel *chn, const char *str)
|
||||
{
|
||||
return bi_putblk(chn, str, strlen(str));
|
||||
return ci_putblk(chn, str, strlen(str));
|
||||
}
|
||||
|
||||
/*
|
||||
* Return one char from the channel's buffer. If the buffer is empty and the
|
||||
* channel is closed, return -2. If the buffer is just empty, return -1. The
|
||||
* buffer's pointer is not advanced, it's up to the caller to call bo_skip(buf,
|
||||
* buffer's pointer is not advanced, it's up to the caller to call co_skip(buf,
|
||||
* 1) when it has consumed the char. Also note that this function respects the
|
||||
* chn->o limit.
|
||||
*/
|
||||
static inline int bo_getchr(struct channel *chn)
|
||||
static inline int co_getchr(struct channel *chn)
|
||||
{
|
||||
/* closed or empty + imminent close = -2; empty = -1 */
|
||||
if (unlikely((chn->flags & CF_SHUTW) || channel_is_empty(chn))) {
|
||||
|
@ -75,7 +75,7 @@ unsigned long long __channel_forward(struct channel *chn, unsigned long long byt
|
||||
* data. Note: this function appends data to the buffer's output and possibly
|
||||
* overwrites any pending input data which are assumed not to exist.
|
||||
*/
|
||||
int bo_inject(struct channel *chn, const char *msg, int len)
|
||||
int co_inject(struct channel *chn, const char *msg, int len)
|
||||
{
|
||||
int max;
|
||||
|
||||
@ -109,7 +109,7 @@ int bo_inject(struct channel *chn, const char *msg, int len)
|
||||
* buffer, -1 is returned. Otherwise the number of bytes copied is returned
|
||||
* (1). Channel flag READ_PARTIAL is updated if some data can be transferred.
|
||||
*/
|
||||
int bi_putchr(struct channel *chn, char c)
|
||||
int ci_putchr(struct channel *chn, char c)
|
||||
{
|
||||
if (unlikely(channel_input_closed(chn)))
|
||||
return -2;
|
||||
@ -140,7 +140,7 @@ int bi_putchr(struct channel *chn, char c)
|
||||
* number). Channel flag READ_PARTIAL is updated if some data can be
|
||||
* transferred.
|
||||
*/
|
||||
int bi_putblk(struct channel *chn, const char *blk, int len)
|
||||
int ci_putblk(struct channel *chn, const char *blk, int len)
|
||||
{
|
||||
int max;
|
||||
|
||||
@ -198,7 +198,7 @@ int bi_putblk(struct channel *chn, const char *blk, int len)
|
||||
* The chunk's length is updated with the number of bytes sent. On errors, NULL
|
||||
* is returned. Note that only buf->i is considered.
|
||||
*/
|
||||
struct buffer *bi_swpbuf(struct channel *chn, struct buffer *buf)
|
||||
struct buffer *ci_swpbuf(struct channel *chn, struct buffer *buf)
|
||||
{
|
||||
struct buffer *old;
|
||||
|
||||
@ -236,12 +236,12 @@ struct buffer *bi_swpbuf(struct channel *chn, struct buffer *buf)
|
||||
* >0 : number of bytes read. Includes the \n if present before len or end.
|
||||
* =0 : no '\n' before end found. <str> is left undefined.
|
||||
* <0 : no more bytes readable because output is shut.
|
||||
* The channel status is not changed. The caller must call bo_skip() to
|
||||
* The channel status is not changed. The caller must call co_skip() to
|
||||
* update it. The '\n' is waited for as long as neither the buffer nor the
|
||||
* output are full. If either of them is full, the string may be returned
|
||||
* as is, without the '\n'.
|
||||
*/
|
||||
int bo_getline(struct channel *chn, char *str, int len)
|
||||
int co_getline(struct channel *chn, char *str, int len)
|
||||
{
|
||||
int ret, max;
|
||||
char *p;
|
||||
@ -287,10 +287,10 @@ int bo_getline(struct channel *chn, char *str, int len)
|
||||
* >0 : number of bytes read, equal to requested size.
|
||||
* =0 : not enough data available. <blk> is left undefined.
|
||||
* <0 : no more bytes readable because output is shut.
|
||||
* The channel status is not changed. The caller must call bo_skip() to
|
||||
* The channel status is not changed. The caller must call co_skip() to
|
||||
* update it.
|
||||
*/
|
||||
int bo_getblk(struct channel *chn, char *blk, int len, int offset)
|
||||
int co_getblk(struct channel *chn, char *blk, int len, int offset)
|
||||
{
|
||||
int firstblock;
|
||||
|
||||
@ -324,10 +324,10 @@ int bo_getblk(struct channel *chn, char *blk, int len, int offset)
|
||||
* >0 : number of blocks filled (1 or 2). blk1 is always filled before blk2.
|
||||
* =0 : not enough data available. <blk*> are left undefined.
|
||||
* <0 : no more bytes readable because output is shut.
|
||||
* The channel status is not changed. The caller must call bo_skip() to
|
||||
* The channel status is not changed. The caller must call co_skip() to
|
||||
* update it. Unused buffers are left in an undefined state.
|
||||
*/
|
||||
int bo_getblk_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)
|
||||
{
|
||||
if (unlikely(chn->buf->o == 0)) {
|
||||
if (chn->flags & CF_SHUTW)
|
||||
@ -357,14 +357,14 @@ int bo_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 bo_getline_nc(struct channel *chn,
|
||||
int co_getline_nc(struct channel *chn,
|
||||
char **blk1, int *len1,
|
||||
char **blk2, int *len2)
|
||||
{
|
||||
int retcode;
|
||||
int l;
|
||||
|
||||
retcode = bo_getblk_nc(chn, blk1, len1, blk2, len2);
|
||||
retcode = co_getblk_nc(chn, blk1, len1, blk2, len2);
|
||||
if (unlikely(retcode) <= 0)
|
||||
return retcode;
|
||||
|
||||
@ -401,7 +401,7 @@ int bo_getline_nc(struct channel *chn,
|
||||
* =0 : not enough data available.
|
||||
* <0 : no more bytes readable because input is shut.
|
||||
*/
|
||||
int bi_getblk_nc(struct channel *chn,
|
||||
int ci_getblk_nc(struct channel *chn,
|
||||
char **blk1, int *len1,
|
||||
char **blk2, int *len2)
|
||||
{
|
||||
@ -433,14 +433,14 @@ int bi_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 bi_getline_nc(struct channel *chn,
|
||||
int ci_getline_nc(struct channel *chn,
|
||||
char **blk1, int *len1,
|
||||
char **blk2, int *len2)
|
||||
{
|
||||
int retcode;
|
||||
int l;
|
||||
|
||||
retcode = bi_getblk_nc(chn, blk1, len1, blk2, len2);
|
||||
retcode = ci_getblk_nc(chn, blk1, len1, blk2, len2);
|
||||
if (unlikely(retcode <= 0))
|
||||
return retcode;
|
||||
|
||||
|
18
src/cli.c
18
src/cli.c
@ -485,7 +485,7 @@ static int cli_output_msg(struct channel *chn, const char *msg, int severity, in
|
||||
struct chunk *tmp;
|
||||
|
||||
if (likely(severity_output == CLI_SEVERITY_NONE))
|
||||
return bi_putblk(chn, msg, strlen(msg));
|
||||
return ci_putblk(chn, msg, strlen(msg));
|
||||
|
||||
tmp = get_trash_chunk();
|
||||
chunk_reset(tmp);
|
||||
@ -508,7 +508,7 @@ static int cli_output_msg(struct channel *chn, const char *msg, int severity, in
|
||||
}
|
||||
chunk_appendf(tmp, "%s", msg);
|
||||
|
||||
return bi_putblk(chn, tmp->str, strlen(tmp->str));
|
||||
return ci_putblk(chn, tmp->str, strlen(tmp->str));
|
||||
}
|
||||
|
||||
/* This I/O handler runs as an applet embedded in a stream interface. It is
|
||||
@ -561,7 +561,7 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
break;
|
||||
}
|
||||
|
||||
reql = bo_getline(si_oc(si), trash.str, trash.size);
|
||||
reql = co_getline(si_oc(si), trash.str, trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
break;
|
||||
@ -642,7 +642,7 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
/* re-adjust req buffer */
|
||||
bo_skip(si_oc(si), reql);
|
||||
co_skip(si_oc(si), reql);
|
||||
req->flags |= CF_READ_DONTWAIT; /* we plan to read small requests */
|
||||
}
|
||||
else { /* output functions */
|
||||
@ -681,7 +681,7 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
|
||||
/* The post-command prompt is either LF alone or LF + '> ' in interactive mode */
|
||||
if (appctx->st0 == CLI_ST_PROMPT) {
|
||||
if (bi_putstr(si_ic(si), appctx->st1 ? "\n> " : "\n") != -1)
|
||||
if (ci_putstr(si_ic(si), appctx->st1 ? "\n> " : "\n") != -1)
|
||||
appctx->st0 = CLI_ST_GETREQ;
|
||||
else
|
||||
si_applet_cant_put(si);
|
||||
@ -771,7 +771,7 @@ static int cli_io_handler_show_env(struct appctx *appctx)
|
||||
while (*var) {
|
||||
chunk_printf(&trash, "%s\n", *var);
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -869,7 +869,7 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
|
||||
|
||||
chunk_appendf(&trash, "\n");
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -899,7 +899,7 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx)
|
||||
switch (appctx->st2) {
|
||||
case STAT_ST_INIT:
|
||||
chunk_printf(&trash, "# socket lvl processes\n");
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -966,7 +966,7 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx)
|
||||
chunk_appendf(&trash, "all\n");
|
||||
}
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2657,7 +2657,7 @@ static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx)
|
||||
}
|
||||
|
||||
/* display response */
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* let's try again later from this session. We add ourselves into
|
||||
* this session's users so that it can remove us upon termination.
|
||||
*/
|
||||
|
@ -1110,7 +1110,7 @@ spoe_send_frame(struct appctx *appctx, char *buf, size_t framesz)
|
||||
* length. */
|
||||
netint = htonl(framesz);
|
||||
memcpy(buf, (char *)&netint, 4);
|
||||
ret = bi_putblk(si_ic(si), buf, framesz+4);
|
||||
ret = ci_putblk(si_ic(si), buf, framesz+4);
|
||||
|
||||
if (ret <= 0) {
|
||||
if (ret == -1) {
|
||||
@ -1137,14 +1137,14 @@ spoe_recv_frame(struct appctx *appctx, char *buf, size_t framesz)
|
||||
if (si_oc(si)->buf == &buf_empty)
|
||||
goto retry;
|
||||
|
||||
ret = bo_getblk(si_oc(si), (char *)&netint, 4, 0);
|
||||
ret = co_getblk(si_oc(si), (char *)&netint, 4, 0);
|
||||
if (ret > 0) {
|
||||
framesz = ntohl(netint);
|
||||
if (framesz > SPOE_APPCTX(appctx)->max_frame_size) {
|
||||
SPOE_APPCTX(appctx)->status_code = SPOE_FRM_ERR_TOO_BIG;
|
||||
return -1;
|
||||
}
|
||||
ret = bo_getblk(si_oc(si), buf, framesz, 4);
|
||||
ret = co_getblk(si_oc(si), buf, framesz, 4);
|
||||
}
|
||||
if (ret <= 0) {
|
||||
if (ret == 0) {
|
||||
@ -1407,7 +1407,7 @@ spoe_handle_connecting_appctx(struct appctx *appctx)
|
||||
next:
|
||||
/* Do not forget to remove processed frame from the output buffer */
|
||||
if (trash.len)
|
||||
bo_skip(si_oc(si), trash.len);
|
||||
co_skip(si_oc(si), trash.len);
|
||||
|
||||
SPOE_APPCTX(appctx)->task->expire =
|
||||
tick_add_ifset(now_ms, agent->timeout.idle);
|
||||
@ -1583,7 +1583,7 @@ spoe_handle_receiving_frame_appctx(struct appctx *appctx, int *skip)
|
||||
|
||||
/* Do not forget to remove processed frame from the output buffer */
|
||||
if (trash.len)
|
||||
bo_skip(si_oc(appctx->owner), trash.len);
|
||||
co_skip(si_oc(appctx->owner), trash.len);
|
||||
end:
|
||||
return ret;
|
||||
}
|
||||
@ -1798,7 +1798,7 @@ spoe_handle_disconnecting_appctx(struct appctx *appctx)
|
||||
next:
|
||||
/* Do not forget to remove processed frame from the output buffer */
|
||||
if (trash.len)
|
||||
bo_skip(si_oc(appctx->owner), trash.len);
|
||||
co_skip(si_oc(appctx->owner), trash.len);
|
||||
|
||||
return 0;
|
||||
stop:
|
||||
|
56
src/hlua.c
56
src/hlua.c
@ -1662,7 +1662,7 @@ __LJMP static int hlua_socket_receive_yield(struct lua_State *L, int status, lua
|
||||
oc = &s->res;
|
||||
if (wanted == HLSR_READ_LINE) {
|
||||
/* Read line. */
|
||||
nblk = bo_getline_nc(oc, &blk1, &len1, &blk2, &len2);
|
||||
nblk = co_getline_nc(oc, &blk1, &len1, &blk2, &len2);
|
||||
if (nblk < 0) /* Connection close. */
|
||||
goto connection_closed;
|
||||
if (nblk == 0) /* No data avalaible. */
|
||||
@ -1693,7 +1693,7 @@ __LJMP static int hlua_socket_receive_yield(struct lua_State *L, int status, lua
|
||||
|
||||
else if (wanted == HLSR_READ_ALL) {
|
||||
/* Read all the available data. */
|
||||
nblk = bo_getblk_nc(oc, &blk1, &len1, &blk2, &len2);
|
||||
nblk = co_getblk_nc(oc, &blk1, &len1, &blk2, &len2);
|
||||
if (nblk < 0) /* Connection close. */
|
||||
goto connection_closed;
|
||||
if (nblk == 0) /* No data avalaible. */
|
||||
@ -1702,7 +1702,7 @@ __LJMP static int hlua_socket_receive_yield(struct lua_State *L, int status, lua
|
||||
|
||||
else {
|
||||
/* Read a block of data. */
|
||||
nblk = bo_getblk_nc(oc, &blk1, &len1, &blk2, &len2);
|
||||
nblk = co_getblk_nc(oc, &blk1, &len1, &blk2, &len2);
|
||||
if (nblk < 0) /* Connection close. */
|
||||
goto connection_closed;
|
||||
if (nblk == 0) /* No data avalaible. */
|
||||
@ -1724,7 +1724,7 @@ __LJMP static int hlua_socket_receive_yield(struct lua_State *L, int status, lua
|
||||
}
|
||||
|
||||
/* Consume data. */
|
||||
bo_skip(oc, len + skip_at_end);
|
||||
co_skip(oc, len + skip_at_end);
|
||||
|
||||
/* Don't wait anything. */
|
||||
stream_int_notify(&s->si[0]);
|
||||
@ -1904,7 +1904,7 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext
|
||||
/* send data */
|
||||
if (len < send_len)
|
||||
send_len = len;
|
||||
len = bi_putblk(&s->req, buf+sent, send_len);
|
||||
len = ci_putblk(&s->req, buf+sent, send_len);
|
||||
|
||||
/* "Not enough space" (-1), "Buffer too little to contain
|
||||
* the data" (-2) are not expected because the available length
|
||||
@ -2551,7 +2551,7 @@ static inline int _hlua_channel_dup(struct channel *chn, lua_State *L)
|
||||
int ret;
|
||||
luaL_Buffer b;
|
||||
|
||||
ret = bi_getblk_nc(chn, &blk1, &len1, &blk2, &len2);
|
||||
ret = ci_getblk_nc(chn, &blk1, &len1, &blk2, &len2);
|
||||
if (unlikely(ret == 0))
|
||||
return 0;
|
||||
|
||||
@ -2643,7 +2643,7 @@ __LJMP static int hlua_channel_getline_yield(lua_State *L, int status, lua_KCont
|
||||
|
||||
chn = MAY_LJMP(hlua_checkchannel(L, 1));
|
||||
|
||||
ret = bi_getline_nc(chn, &blk1, &len1, &blk2, &len2);
|
||||
ret = ci_getline_nc(chn, &blk1, &len1, &blk2, &len2);
|
||||
if (ret == 0)
|
||||
WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_channel_getline_yield, TICK_ETERNITY, 0));
|
||||
|
||||
@ -2701,7 +2701,7 @@ __LJMP static int hlua_channel_append_yield(lua_State *L, int status, lua_KConte
|
||||
if (max > len - l)
|
||||
max = len - l;
|
||||
|
||||
ret = bi_putblk(chn, str + l, max);
|
||||
ret = ci_putblk(chn, str + l, max);
|
||||
if (ret == -2 || ret == -3) {
|
||||
lua_pushinteger(L, -1);
|
||||
return 1;
|
||||
@ -3411,7 +3411,7 @@ __LJMP static int hlua_applet_tcp_getline_yield(lua_State *L, int status, lua_KC
|
||||
int len2;
|
||||
|
||||
/* Read the maximum amount of data avalaible. */
|
||||
ret = bo_getline_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
|
||||
ret = co_getline_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
|
||||
|
||||
/* Data not yet avalaible. return yield. */
|
||||
if (ret == 0) {
|
||||
@ -3434,7 +3434,7 @@ __LJMP static int hlua_applet_tcp_getline_yield(lua_State *L, int status, lua_KC
|
||||
luaL_addlstring(&appctx->b, blk2, len2);
|
||||
|
||||
/* Consume input channel output buffer data. */
|
||||
bo_skip(si_oc(si), len1 + len2);
|
||||
co_skip(si_oc(si), len1 + len2);
|
||||
luaL_pushresult(&appctx->b);
|
||||
return 1;
|
||||
}
|
||||
@ -3466,7 +3466,7 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont
|
||||
int len2;
|
||||
|
||||
/* Read the maximum amount of data avalaible. */
|
||||
ret = bo_getblk_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
|
||||
ret = co_getblk_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
|
||||
|
||||
/* Data not yet avalaible. return yield. */
|
||||
if (ret == 0) {
|
||||
@ -3492,7 +3492,7 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont
|
||||
*/
|
||||
luaL_addlstring(&appctx->b, blk1, len1);
|
||||
luaL_addlstring(&appctx->b, blk2, len2);
|
||||
bo_skip(si_oc(si), len1 + len2);
|
||||
co_skip(si_oc(si), len1 + len2);
|
||||
si_applet_cant_get(si);
|
||||
WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_recv_yield, TICK_ETERNITY, 0));
|
||||
|
||||
@ -3511,7 +3511,7 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont
|
||||
len -= len2;
|
||||
|
||||
/* Consume input channel output buffer data. */
|
||||
bo_skip(si_oc(si), len1 + len2);
|
||||
co_skip(si_oc(si), len1 + len2);
|
||||
|
||||
/* If we are no other data avalaible, yield waiting for new data. */
|
||||
if (len > 0) {
|
||||
@ -3575,7 +3575,7 @@ __LJMP static int hlua_applet_tcp_send_yield(lua_State *L, int status, lua_KCont
|
||||
max = len - l;
|
||||
|
||||
/* Copy data. */
|
||||
bi_putblk(chn, str + l, max);
|
||||
ci_putblk(chn, str + l, max);
|
||||
|
||||
/* update counters. */
|
||||
l += max;
|
||||
@ -3875,7 +3875,7 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K
|
||||
|
||||
/* Maybe we cant send a 100-continue ? */
|
||||
if (appctx->appctx->ctx.hlua_apphttp.flags & APPLET_100C) {
|
||||
ret = bi_putblk(chn, HTTP_100C, strlen(HTTP_100C));
|
||||
ret = ci_putblk(chn, HTTP_100C, strlen(HTTP_100C));
|
||||
/* if ret == -2 or -3 the channel closed or the message si too
|
||||
* big for the buffers. We cant send anything. So, we ignoring
|
||||
* the error, considers that the 100-continue is sent, and try
|
||||
@ -3896,7 +3896,7 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K
|
||||
}
|
||||
|
||||
/* Read the maximum amount of data avalaible. */
|
||||
ret = bo_getline_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
|
||||
ret = co_getline_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
|
||||
|
||||
/* Data not yet avalaible. return yield. */
|
||||
if (ret == 0) {
|
||||
@ -3927,7 +3927,7 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K
|
||||
appctx->appctx->ctx.hlua_apphttp.left_bytes -= len2;
|
||||
|
||||
/* Consume input channel output buffer data. */
|
||||
bo_skip(si_oc(si), len1 + len2);
|
||||
co_skip(si_oc(si), len1 + len2);
|
||||
luaL_pushresult(&appctx->b);
|
||||
return 1;
|
||||
}
|
||||
@ -3961,7 +3961,7 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon
|
||||
|
||||
/* Maybe we cant send a 100-continue ? */
|
||||
if (appctx->appctx->ctx.hlua_apphttp.flags & APPLET_100C) {
|
||||
ret = bi_putblk(chn, HTTP_100C, strlen(HTTP_100C));
|
||||
ret = ci_putblk(chn, HTTP_100C, strlen(HTTP_100C));
|
||||
/* if ret == -2 or -3 the channel closed or the message si too
|
||||
* big for the buffers. We cant send anything. So, we ignoring
|
||||
* the error, considers that the 100-continue is sent, and try
|
||||
@ -3976,7 +3976,7 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon
|
||||
}
|
||||
|
||||
/* Read the maximum amount of data avalaible. */
|
||||
ret = bo_getblk_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
|
||||
ret = co_getblk_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
|
||||
|
||||
/* Data not yet avalaible. return yield. */
|
||||
if (ret == 0) {
|
||||
@ -4007,7 +4007,7 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon
|
||||
len -= len2;
|
||||
|
||||
/* Consume input channel output buffer data. */
|
||||
bo_skip(si_oc(si), len1 + len2);
|
||||
co_skip(si_oc(si), len1 + len2);
|
||||
if (appctx->appctx->ctx.hlua_apphttp.left_bytes != -1)
|
||||
appctx->appctx->ctx.hlua_apphttp.left_bytes -= len;
|
||||
|
||||
@ -4070,7 +4070,7 @@ __LJMP static int hlua_applet_http_send_yield(lua_State *L, int status, lua_KCon
|
||||
max = len - l;
|
||||
|
||||
/* Copy data. */
|
||||
bi_putblk(chn, str + l, max);
|
||||
ci_putblk(chn, str + l, max);
|
||||
|
||||
/* update counters. */
|
||||
l += max;
|
||||
@ -4209,7 +4209,7 @@ __LJMP static int hlua_applet_http_start_response_yield(lua_State *L, int status
|
||||
msg = MAY_LJMP(luaL_checklstring(L, 2, &len));
|
||||
|
||||
/* Send the message at once. */
|
||||
ret = bi_putblk(chn, msg, len);
|
||||
ret = ci_putblk(chn, msg, len);
|
||||
|
||||
/* if ret == -2 or -3 the channel closed or the message si too
|
||||
* big for the buffers.
|
||||
@ -6136,7 +6136,7 @@ static void hlua_applet_tcp_fct(struct appctx *ctx)
|
||||
strm->logs.tv_request = now;
|
||||
|
||||
/* eat the whole request */
|
||||
bo_skip(si_oc(si), si_ob(si)->o);
|
||||
co_skip(si_oc(si), si_ob(si)->o);
|
||||
res->flags |= CF_READ_NULL;
|
||||
si_shutr(si);
|
||||
return;
|
||||
@ -6352,7 +6352,7 @@ static void hlua_applet_http_fct(struct appctx *ctx)
|
||||
*/
|
||||
|
||||
/* Read the maximum amount of data avalaible. */
|
||||
ret = bo_getblk_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
|
||||
ret = co_getblk_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
|
||||
if (ret == -1)
|
||||
return;
|
||||
|
||||
@ -6367,7 +6367,7 @@ static void hlua_applet_http_fct(struct appctx *ctx)
|
||||
}
|
||||
|
||||
/* skip the requests bytes. */
|
||||
bo_skip(si_oc(si), strm->txn->req.eoh + 2);
|
||||
co_skip(si_oc(si), strm->txn->req.eoh + 2);
|
||||
}
|
||||
|
||||
/* Executes The applet if it is not done. */
|
||||
@ -6412,7 +6412,7 @@ static void hlua_applet_http_fct(struct appctx *ctx)
|
||||
!(ctx->ctx.hlua_apphttp.flags & APPLET_LAST_CHK)) {
|
||||
|
||||
/* sent last chunk at once. */
|
||||
ret = bi_putblk(res, "0\r\n\r\n", 5);
|
||||
ret = ci_putblk(res, "0\r\n\r\n", 5);
|
||||
|
||||
/* critical error. */
|
||||
if (ret == -2 || ret == -3) {
|
||||
@ -6438,7 +6438,7 @@ static void hlua_applet_http_fct(struct appctx *ctx)
|
||||
strm->logs.tv_request = now;
|
||||
|
||||
/* eat the whole request */
|
||||
bo_skip(si_oc(si), si_ob(si)->o);
|
||||
co_skip(si_oc(si), si_ob(si)->o);
|
||||
res->flags |= CF_READ_NULL;
|
||||
si_shutr(si);
|
||||
|
||||
@ -6452,7 +6452,7 @@ static void hlua_applet_http_fct(struct appctx *ctx)
|
||||
* if there are no room avalaible in the buffer,
|
||||
* just close the connection.
|
||||
*/
|
||||
bi_putblk(res, error_500, strlen(error_500));
|
||||
ci_putblk(res, error_500, strlen(error_500));
|
||||
if (!(strm->flags & SF_ERR_MASK))
|
||||
strm->flags |= SF_ERR_RESOURCE;
|
||||
si_shutw(si);
|
||||
|
@ -350,7 +350,7 @@ static int cli_io_handler_pat_list(struct appctx *appctx)
|
||||
chunk_appendf(&trash, "%p %s\n",
|
||||
elt, elt->pattern);
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* let's try again later from this stream. We add ourselves into
|
||||
* this stream's users so that it can remove us upon termination.
|
||||
*/
|
||||
@ -384,7 +384,7 @@ static int cli_io_handler_pats_list(struct appctx *appctx)
|
||||
*/
|
||||
chunk_reset(&trash);
|
||||
chunk_appendf(&trash, "# id (file) description\n");
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -411,7 +411,7 @@ static int cli_io_handler_pats_list(struct appctx *appctx)
|
||||
appctx->ctx.map.ref->reference ? appctx->ctx.map.ref->reference : "",
|
||||
appctx->ctx.map.ref->display);
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* let's try again later from this stream. We add ourselves into
|
||||
* this stream's users so that it can remove us upon termination.
|
||||
*/
|
||||
@ -530,7 +530,7 @@ static int cli_io_handler_map_lookup(struct appctx *appctx)
|
||||
chunk_appendf(&trash, "\n");
|
||||
|
||||
/* display response */
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* let's try again later from this stream. We add ourselves into
|
||||
* this stream's users so that it can remove us upon termination.
|
||||
*/
|
||||
|
@ -282,7 +282,7 @@ static int cli_io_handler_dump_pools(struct appctx *appctx)
|
||||
struct stream_interface *si = appctx->owner;
|
||||
|
||||
dump_pools_to_trash();
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
|
58
src/peers.c
58
src/peers.c
@ -581,7 +581,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
appctx->st0 = PEER_SESS_ST_GETVERSION;
|
||||
/* fall through */
|
||||
case PEER_SESS_ST_GETVERSION:
|
||||
reql = bo_getline(si_oc(si), trash.str, trash.size);
|
||||
reql = co_getline(si_oc(si), trash.str, trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
@ -597,7 +597,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
else
|
||||
trash.str[reql-1] = 0;
|
||||
|
||||
bo_skip(si_oc(si), reql);
|
||||
co_skip(si_oc(si), reql);
|
||||
|
||||
/* test protocol */
|
||||
if (strncmp(PEER_SESSION_PROTO_NAME " ", trash.str, proto_len + 1) != 0) {
|
||||
@ -615,7 +615,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
appctx->st0 = PEER_SESS_ST_GETHOST;
|
||||
/* fall through */
|
||||
case PEER_SESS_ST_GETHOST:
|
||||
reql = bo_getline(si_oc(si), trash.str, trash.size);
|
||||
reql = co_getline(si_oc(si), trash.str, trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
@ -631,7 +631,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
else
|
||||
trash.str[reql-1] = 0;
|
||||
|
||||
bo_skip(si_oc(si), reql);
|
||||
co_skip(si_oc(si), reql);
|
||||
|
||||
/* test hostname match */
|
||||
if (strcmp(localpeer, trash.str) != 0) {
|
||||
@ -645,7 +645,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
case PEER_SESS_ST_GETPEER: {
|
||||
struct peer *curpeer;
|
||||
char *p;
|
||||
reql = bo_getline(si_oc(si), trash.str, trash.size);
|
||||
reql = co_getline(si_oc(si), trash.str, trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
@ -662,7 +662,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
else
|
||||
trash.str[reql-1] = 0;
|
||||
|
||||
bo_skip(si_oc(si), reql);
|
||||
co_skip(si_oc(si), reql);
|
||||
|
||||
/* parse line "<peer name> <pid> <relative_pid>" */
|
||||
p = strchr(trash.str, ' ');
|
||||
@ -713,7 +713,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
struct shared_table *st;
|
||||
|
||||
repl = snprintf(trash.str, trash.size, "%d\n", PEER_SESS_SC_SUCCESSCODE);
|
||||
repl = bi_putblk(si_ic(si), trash.str, repl);
|
||||
repl = ci_putblk(si_ic(si), trash.str, repl);
|
||||
if (repl <= 0) {
|
||||
if (repl == -1)
|
||||
goto full;
|
||||
@ -781,7 +781,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
repl = bi_putblk(si_ic(si), trash.str, repl);
|
||||
repl = ci_putblk(si_ic(si), trash.str, repl);
|
||||
if (repl <= 0) {
|
||||
if (repl == -1)
|
||||
goto full;
|
||||
@ -800,7 +800,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
if (si_ic(si)->flags & CF_WRITE_PARTIAL)
|
||||
curpeer->statuscode = PEER_SESS_SC_CONNECTEDCODE;
|
||||
|
||||
reql = bo_getline(si_oc(si), trash.str, trash.size);
|
||||
reql = co_getline(si_oc(si), trash.str, trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
@ -817,7 +817,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
else
|
||||
trash.str[reql-1] = 0;
|
||||
|
||||
bo_skip(si_oc(si), reql);
|
||||
co_skip(si_oc(si), reql);
|
||||
|
||||
/* Register status code */
|
||||
curpeer->statuscode = atoi(trash.str);
|
||||
@ -876,7 +876,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
unsigned char msg_head[7];
|
||||
int totl = 0;
|
||||
|
||||
reql = bo_getblk(si_oc(si), (char *)msg_head, 2*sizeof(unsigned char), totl);
|
||||
reql = co_getblk(si_oc(si), (char *)msg_head, 2*sizeof(unsigned char), totl);
|
||||
if (reql <= 0) /* closed or EOL not found */
|
||||
goto incomplete;
|
||||
|
||||
@ -884,7 +884,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
|
||||
if (msg_head[1] >= 128) {
|
||||
/* Read and Decode message length */
|
||||
reql = bo_getblk(si_oc(si), (char *)&msg_head[2], sizeof(unsigned char), totl);
|
||||
reql = co_getblk(si_oc(si), (char *)&msg_head[2], sizeof(unsigned char), totl);
|
||||
if (reql <= 0) /* closed */
|
||||
goto incomplete;
|
||||
|
||||
@ -899,7 +899,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
char *end;
|
||||
|
||||
for (i = 3 ; i < sizeof(msg_head) ; i++) {
|
||||
reql = bo_getblk(si_oc(si), (char *)&msg_head[i], sizeof(char), totl);
|
||||
reql = co_getblk(si_oc(si), (char *)&msg_head[i], sizeof(char), totl);
|
||||
if (reql <= 0) /* closed */
|
||||
goto incomplete;
|
||||
|
||||
@ -934,7 +934,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
reql = bo_getblk(si_oc(si), trash.str, msg_len, totl);
|
||||
reql = co_getblk(si_oc(si), trash.str, msg_len, totl);
|
||||
if (reql <= 0) /* closed */
|
||||
goto incomplete;
|
||||
totl += reql;
|
||||
@ -1332,12 +1332,12 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
|
||||
ignore_msg:
|
||||
/* skip consumed message */
|
||||
bo_skip(si_oc(si), totl);
|
||||
co_skip(si_oc(si), totl);
|
||||
/* loop on that state to peek next message */
|
||||
goto switchstate;
|
||||
|
||||
incomplete:
|
||||
/* we get here when a bo_getblk() returns <= 0 in reql */
|
||||
/* we get here when a co_getblk() returns <= 0 in reql */
|
||||
|
||||
if (reql < 0) {
|
||||
/* there was an error */
|
||||
@ -1359,7 +1359,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
msg[1] = PEER_MSG_CTRL_RESYNCREQ;
|
||||
|
||||
/* message to buffer */
|
||||
repl = bi_putblk(si_ic(si), (char *)msg, sizeof(msg));
|
||||
repl = ci_putblk(si_ic(si), (char *)msg, sizeof(msg));
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1)
|
||||
@ -1397,7 +1397,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = bi_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1) {
|
||||
@ -1426,7 +1426,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = bi_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1) {
|
||||
@ -1468,7 +1468,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = bi_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1) {
|
||||
@ -1503,7 +1503,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = bi_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1) {
|
||||
@ -1542,7 +1542,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = bi_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1) {
|
||||
@ -1574,7 +1574,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = bi_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1) {
|
||||
@ -1610,7 +1610,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = bi_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1) {
|
||||
@ -1642,7 +1642,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
msg[0] = PEER_MSG_CLASS_CONTROL;
|
||||
msg[1] = ((curpeers->flags & PEERS_RESYNC_STATEMASK) == PEERS_RESYNC_FINISHED) ? PEER_MSG_CTRL_RESYNCFINISHED : PEER_MSG_CTRL_RESYNCPARTIAL;
|
||||
/* process final lesson message */
|
||||
repl = bi_putblk(si_ic(si), (char *)msg, sizeof(msg));
|
||||
repl = ci_putblk(si_ic(si), (char *)msg, sizeof(msg));
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1)
|
||||
@ -1663,7 +1663,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
msg[1] = PEER_MSG_CTRL_RESYNCCONFIRM;
|
||||
|
||||
/* message to buffer */
|
||||
repl = bi_putblk(si_ic(si), (char *)msg, sizeof(msg));
|
||||
repl = ci_putblk(si_ic(si), (char *)msg, sizeof(msg));
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1)
|
||||
@ -1679,7 +1679,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
}
|
||||
case PEER_SESS_ST_EXIT:
|
||||
repl = snprintf(trash.str, trash.size, "%d\n", appctx->st1);
|
||||
if (bi_putblk(si_ic(si), trash.str, repl) == -1)
|
||||
if (ci_putblk(si_ic(si), trash.str, repl) == -1)
|
||||
goto full;
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
@ -1689,7 +1689,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
msg[0] = PEER_MSG_CLASS_ERROR;
|
||||
msg[1] = PEER_MSG_ERR_SIZELIMIT;
|
||||
|
||||
if (bi_putblk(si_ic(si), (char *)msg, sizeof(msg)) == -1)
|
||||
if (ci_putblk(si_ic(si), (char *)msg, sizeof(msg)) == -1)
|
||||
goto full;
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
@ -1700,7 +1700,7 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
msg[0] = PEER_MSG_CLASS_ERROR;
|
||||
msg[1] = PEER_MSG_ERR_PROTOCOL;
|
||||
|
||||
if (bi_putblk(si_ic(si), (char *)msg, sizeof(msg)) == -1)
|
||||
if (ci_putblk(si_ic(si), (char *)msg, sizeof(msg)) == -1)
|
||||
goto full;
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
/* fall through */
|
||||
|
@ -1051,7 +1051,7 @@ static void http_server_error(struct stream *s, struct stream_interface *si,
|
||||
channel_auto_close(si_ic(si));
|
||||
channel_auto_read(si_ic(si));
|
||||
if (msg)
|
||||
bo_inject(si_ic(si), msg->str, msg->len);
|
||||
co_inject(si_ic(si), msg->str, msg->len);
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= err;
|
||||
if (!(s->flags & SF_FINST_MASK))
|
||||
@ -4225,7 +4225,7 @@ static int http_apply_redirect_rule(struct redirect_rule *rule, struct stream *s
|
||||
memcpy(chunk->str + chunk->len, "\r\n\r\n", 4);
|
||||
chunk->len += 4;
|
||||
FLT_STRM_CB(s, flt_http_reply(s, txn->status, chunk));
|
||||
bo_inject(res->chn, chunk->str, chunk->len);
|
||||
co_inject(res->chn, chunk->str, chunk->len);
|
||||
/* "eat" the request */
|
||||
bi_fast_delete(req->chn->buf, req->sov);
|
||||
req->next -= req->sov;
|
||||
@ -4927,7 +4927,7 @@ int http_wait_for_request_body(struct stream *s, struct channel *req, int an_bit
|
||||
/* Expect is allowed in 1.1, look for it */
|
||||
if (http_find_header2("Expect", 6, req->buf->p, &txn->hdr_idx, &ctx) &&
|
||||
unlikely(ctx.vlen == 12 && strncasecmp(ctx.line+ctx.val, "100-continue", 12) == 0)) {
|
||||
bo_inject(&s->res, http_100_chunk.str, http_100_chunk.len);
|
||||
co_inject(&s->res, http_100_chunk.str, http_100_chunk.len);
|
||||
http_remove_header2(&txn->req, &txn->hdr_idx, &ctx);
|
||||
}
|
||||
}
|
||||
@ -13157,7 +13157,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec, (int)(date.tv_usec/1000),
|
||||
error_snapshot_id);
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* Socket buffer full. Let's try again later from the same point */
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
@ -13247,7 +13247,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
|
||||
es->b_flags, es->b_out, es->b_tot,
|
||||
es->len, es->b_wrap, es->pos);
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* Socket buffer full. Let's try again later from the same point */
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
@ -13260,7 +13260,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
|
||||
/* the snapshot changed while we were dumping it */
|
||||
chunk_appendf(&trash,
|
||||
" WARNING! update detected on this snapshot, dump interrupted. Please re-check!\n");
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -13277,7 +13277,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
|
||||
if (newptr == appctx->ctx.errors.ptr)
|
||||
return 0;
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* Socket buffer full. Let's try again later from the same point */
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
|
@ -1467,7 +1467,7 @@ static int dump_servers_state(struct stream_interface *si, struct chunk *buf)
|
||||
srv->cur_state, srv->cur_admin, srv->uweight, srv->iweight, (long int)srv_time_since_last_change,
|
||||
srv->check.status, srv->check.result, srv->check.health, srv->check.state, srv->agent.state,
|
||||
bk_f_forced_id, srv_f_forced_id, srv->hostname ? srv->hostname : "-", srv->svc_port);
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -1495,7 +1495,7 @@ static int cli_io_handler_servers_state(struct appctx *appctx)
|
||||
|
||||
if (appctx->st2 == STAT_ST_HEAD) {
|
||||
chunk_printf(&trash, "%d\n# %s\n", SRV_STATE_FILE_VERSION, SRV_STATE_FILE_FIELD_NAMES);
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -1531,7 +1531,7 @@ static int cli_io_handler_show_backend(struct appctx *appctx)
|
||||
|
||||
if (!appctx->ctx.cli.p0) {
|
||||
chunk_printf(&trash, "# name\n");
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -1550,7 +1550,7 @@ static int cli_io_handler_show_backend(struct appctx *appctx)
|
||||
continue;
|
||||
|
||||
chunk_appendf(&trash, "%s\n", curproxy->id);
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
|
@ -4232,7 +4232,7 @@ static int cli_parse_get_weight(char **args, struct appctx *appctx, void *privat
|
||||
|
||||
/* return server's effective weight at the moment */
|
||||
snprintf(trash.str, trash.size, "%d (initial %d)\n", sv->uweight, sv->iweight);
|
||||
if (bi_putstr(si_ic(si), trash.str) == -1) {
|
||||
if (ci_putstr(si_ic(si), trash.str) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
|
@ -7718,7 +7718,7 @@ static int cli_io_handler_tlskeys_files(struct appctx *appctx) {
|
||||
else
|
||||
chunk_appendf(&trash, "# id (file)\n");
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -7758,7 +7758,7 @@ static int cli_io_handler_tlskeys_files(struct appctx *appctx) {
|
||||
sizeof(struct tls_sess_key), t2->str, t2->size);
|
||||
chunk_appendf(&trash, "%d.%d %s\n", ref->unique_id, appctx->ctx.cli.i1, t2->str);
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* let's try again later from this stream. We add ourselves into
|
||||
* this stream's users so that it can remove us upon termination.
|
||||
*/
|
||||
@ -7769,7 +7769,7 @@ static int cli_io_handler_tlskeys_files(struct appctx *appctx) {
|
||||
}
|
||||
appctx->ctx.cli.i1 = 0;
|
||||
}
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* let's try again later from this stream. We add ourselves into
|
||||
* this stream's users so that it can remove us upon termination.
|
||||
*/
|
||||
|
36
src/stats.c
36
src/stats.c
@ -2008,7 +2008,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy *px, st
|
||||
case STAT_PX_ST_TH:
|
||||
if (appctx->ctx.stats.flags & STAT_FMT_HTML) {
|
||||
stats_dump_html_px_hdr(si, px, uri);
|
||||
if (bi_putchk(rep, &trash) == -1) {
|
||||
if (ci_putchk(rep, &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2020,7 +2020,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy *px, st
|
||||
case STAT_PX_ST_FE:
|
||||
/* print the frontend */
|
||||
if (stats_dump_fe_stats(si, px)) {
|
||||
if (bi_putchk(rep, &trash) == -1) {
|
||||
if (ci_putchk(rep, &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2052,7 +2052,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy *px, st
|
||||
|
||||
/* print the frontend */
|
||||
if (stats_dump_li_stats(si, px, l, flags)) {
|
||||
if (bi_putchk(rep, &trash) == -1) {
|
||||
if (ci_putchk(rep, &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2096,7 +2096,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy *px, st
|
||||
}
|
||||
|
||||
if (stats_dump_sv_stats(si, px, flags, sv)) {
|
||||
if (bi_putchk(rep, &trash) == -1) {
|
||||
if (ci_putchk(rep, &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2109,7 +2109,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy *px, st
|
||||
case STAT_PX_ST_BE:
|
||||
/* print the backend */
|
||||
if (stats_dump_be_stats(si, px, flags)) {
|
||||
if (bi_putchk(rep, &trash) == -1) {
|
||||
if (ci_putchk(rep, &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2121,7 +2121,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy *px, st
|
||||
case STAT_PX_ST_END:
|
||||
if (appctx->ctx.stats.flags & STAT_FMT_HTML) {
|
||||
stats_dump_html_px_end(si, px);
|
||||
if (bi_putchk(rep, &trash) == -1) {
|
||||
if (ci_putchk(rep, &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2533,7 +2533,7 @@ static int stats_dump_stat_to_buffer(struct stream_interface *si, struct uri_aut
|
||||
else if (!(appctx->ctx.stats.flags & STAT_FMT_TYPED))
|
||||
stats_dump_csv_header();
|
||||
|
||||
if (bi_putchk(rep, &trash) == -1) {
|
||||
if (ci_putchk(rep, &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2544,7 +2544,7 @@ static int stats_dump_stat_to_buffer(struct stream_interface *si, struct uri_aut
|
||||
case STAT_ST_INFO:
|
||||
if (appctx->ctx.stats.flags & STAT_FMT_HTML) {
|
||||
stats_dump_html_info(si, uri);
|
||||
if (bi_putchk(rep, &trash) == -1) {
|
||||
if (ci_putchk(rep, &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2583,7 +2583,7 @@ static int stats_dump_stat_to_buffer(struct stream_interface *si, struct uri_aut
|
||||
stats_dump_html_end();
|
||||
else
|
||||
stats_dump_json_end();
|
||||
if (bi_putchk(rep, &trash) == -1) {
|
||||
if (ci_putchk(rep, &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2636,7 +2636,7 @@ static int stats_process_http_post(struct stream_interface *si)
|
||||
goto out;
|
||||
}
|
||||
|
||||
reql = bo_getblk(si_oc(si), temp->str, s->txn->req.body_len, s->txn->req.eoh + 2);
|
||||
reql = co_getblk(si_oc(si), temp->str, s->txn->req.body_len, s->txn->req.eoh + 2);
|
||||
if (reql <= 0) {
|
||||
/* we need more data */
|
||||
appctx->ctx.stats.st_code = STAT_STATUS_NONE;
|
||||
@ -2953,7 +2953,7 @@ static int stats_send_http_headers(struct stream_interface *si)
|
||||
s->txn->status = 200;
|
||||
s->logs.tv_request = now;
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -3001,7 +3001,7 @@ static int stats_send_http_redirect(struct stream_interface *si)
|
||||
s->txn->status = 303;
|
||||
s->logs.tv_request = now;
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -3060,7 +3060,7 @@ static void http_stats_io_handler(struct appctx *appctx)
|
||||
last_fwd = si_ic(si)->to_forward;
|
||||
si_ic(si)->to_forward = 0;
|
||||
chunk_printf(&trash, "\r\n000000\r\n");
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
si_ic(si)->to_forward = last_fwd;
|
||||
goto out;
|
||||
@ -3086,7 +3086,7 @@ static void http_stats_io_handler(struct appctx *appctx)
|
||||
|
||||
if (last_len != data_len) {
|
||||
chunk_printf(&trash, "\r\n%06x\r\n", (last_len - data_len));
|
||||
if (bi_putchk(si_ic(si), &trash) == -1)
|
||||
if (ci_putchk(si_ic(si), &trash) == -1)
|
||||
si_applet_cant_put(si);
|
||||
|
||||
si_ic(si)->total += (last_len - data_len);
|
||||
@ -3112,13 +3112,13 @@ static void http_stats_io_handler(struct appctx *appctx)
|
||||
if (appctx->st0 == STAT_HTTP_DONE) {
|
||||
if (appctx->ctx.stats.flags & STAT_CHUNKED) {
|
||||
chunk_printf(&trash, "\r\n0\r\n\r\n");
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
/* eat the whole request */
|
||||
bo_skip(si_oc(si), si_ob(si)->o);
|
||||
co_skip(si_oc(si), si_ob(si)->o);
|
||||
res->flags |= CF_READ_NULL;
|
||||
si_shutr(si);
|
||||
}
|
||||
@ -3290,7 +3290,7 @@ static int stats_dump_info_to_buffer(struct stream_interface *si)
|
||||
else
|
||||
stats_dump_info_fields(&trash, info);
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -3518,7 +3518,7 @@ static int stats_dump_json_schema_to_buffer(struct stream_interface *si)
|
||||
|
||||
stats_dump_json_schema(&trash);
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2256,7 +2256,7 @@ static int table_dump_head_to_buffer(struct chunk *msg, struct stream_interface
|
||||
if (target && (strm_li(s)->bind_conf->level & ACCESS_LVL_MASK) < ACCESS_LVL_OPER)
|
||||
chunk_appendf(msg, "# contents not dumped due to insufficient privileges\n");
|
||||
|
||||
if (bi_putchk(si_ic(si), msg) == -1) {
|
||||
if (ci_putchk(si_ic(si), msg) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2329,7 +2329,7 @@ static int table_dump_entry_to_buffer(struct chunk *msg, struct stream_interface
|
||||
}
|
||||
chunk_appendf(msg, "\n");
|
||||
|
||||
if (bi_putchk(si_ic(si), msg) == -1) {
|
||||
if (ci_putchk(si_ic(si), msg) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2662,7 +2662,7 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st
|
||||
if (appctx->ctx.sess.section > 0 && appctx->ctx.sess.uid != strm->uniq_id) {
|
||||
/* stream changed, no need to go any further */
|
||||
chunk_appendf(&trash, " *** session terminated while we were watching it ***\n");
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -2945,7 +2945,7 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st
|
||||
strm->txn ? strm->txn->rsp.next : 0, strm->res.buf->i,
|
||||
strm->res.buf->size);
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -3156,7 +3156,7 @@ static int cli_io_handler_dump_sess(struct appctx *appctx)
|
||||
|
||||
chunk_appendf(&trash, "\n");
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* let's try again later from this stream. We add ourselves into
|
||||
* this stream's users so that it can remove us upon termination.
|
||||
*/
|
||||
@ -3176,7 +3176,7 @@ static int cli_io_handler_dump_sess(struct appctx *appctx)
|
||||
else
|
||||
chunk_appendf(&trash, "Session not found.\n");
|
||||
|
||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ void stream_int_retnclose(struct stream_interface *si, const struct chunk *msg)
|
||||
channel_truncate(oc);
|
||||
|
||||
if (likely(msg && msg->len))
|
||||
bo_inject(oc, msg->str, msg->len);
|
||||
co_inject(oc, msg->str, msg->len);
|
||||
|
||||
oc->wex = tick_add_ifset(now_ms, oc->wto);
|
||||
channel_auto_read(oc);
|
||||
|
Loading…
Reference in New Issue
Block a user