diff --git a/src/activity.c b/src/activity.c index a84925de5..1b938a23c 100644 --- a/src/activity.c +++ b/src/activity.c @@ -647,9 +647,8 @@ static int cli_io_handler_show_profiling(struct appctx *appctx) "Memory usage profiling : %-8s # set profiling memory {on|off}\n", str, (profiling & HA_PROF_MEMORY) ? "on" : "off"); - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &trash) == -1) { /* failed, try again */ - cs_rx_room_blk(cs); return 0; } @@ -697,16 +696,14 @@ static int cli_io_handler_show_profiling(struct appctx *appctx) print_time_short(&trash, " ", tmp_activity[i].lat_time, ""); print_time_short(&trash, " ", tmp_activity[i].lat_time / tmp_activity[i].calls, "\n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &trash) == -1) { /* failed, try again */ - cs_rx_room_blk(cs); return 0; } } - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &trash) == -1) { /* failed, try again */ - cs_rx_room_blk(cs); return 0; } @@ -762,16 +759,12 @@ static int cli_io_handler_show_profiling(struct appctx *appctx) chunk_appendf(&trash, "\n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } } - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } tot_alloc_calls = tot_free_calls = tot_alloc_bytes = tot_free_bytes = 0; for (i = 0; i < max_lines; i++) { @@ -789,10 +782,8 @@ static int cli_io_handler_show_profiling(struct appctx *appctx) tot_alloc_calls - tot_free_calls, tot_alloc_bytes - tot_free_bytes); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } ctx->linenum = 0; // reset first line to dump if ((ctx->dump_step & 4) == 0) @@ -976,9 +967,8 @@ static int cli_io_handler_show_tasks(struct appctx *appctx) print_time_short(&trash, " ", tmp_activity[i].lat_time / tmp_activity[i].calls, "\n"); } - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &trash) == -1) { /* failed, try again */ - cs_rx_room_blk(cs); return 0; } return 1; diff --git a/src/cache.c b/src/cache.c index 8a79ef05c..f28ff8952 100644 --- a/src/cache.c +++ b/src/cache.c @@ -2600,7 +2600,6 @@ static int cli_io_handler_show_cache(struct appctx *appctx) { struct show_cache_ctx *ctx = appctx->svcctx; struct cache* cache = ctx->cache; - struct stconn *cs = appctx_cs(appctx); list_for_each_entry_from(cache, &caches, list) { struct eb32_node *node = NULL; @@ -2611,10 +2610,8 @@ static int cli_io_handler_show_cache(struct appctx *appctx) next_key = ctx->next_key; if (!next_key) { chunk_printf(&trash, "%p: %s (shctx:%p, available blocks:%d)\n", cache, cache->id, shctx_ptr(cache), shctx_ptr(cache)->nbav); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } } ctx->cache = cache; @@ -2649,10 +2646,8 @@ static int cli_io_handler_show_cache(struct appctx *appctx) shctx_unlock(shctx_ptr(cache)); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } } } diff --git a/src/cli.c b/src/cli.c index 273fe8684..95d487d50 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1131,10 +1131,8 @@ static void cli_io_handler(struct appctx *appctx) prompt = "\n"; } - if (ci_putstr(cs_ic(cs), prompt) != -1) + if (applet_putstr(appctx, prompt) != -1) appctx->st0 = CLI_ST_GETREQ; - else - cs_rx_room_blk(cs); } /* If the output functions are still there, it means they require more room. */ @@ -1240,10 +1238,9 @@ static int cli_io_handler_show_env(struct appctx *appctx) while (*var) { chunk_printf(&trash, "%s\n", *var); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } + if (ctx->show_one) break; var++; @@ -1434,8 +1431,7 @@ static int cli_io_handler_show_fd(struct appctx *appctx) #endif chunk_appendf(&trash, "%s\n", suspicious ? " !" : ""); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) { fdctx->fd = fd; ret = 0; break; @@ -1546,10 +1542,9 @@ static int cli_io_handler_show_activity(struct appctx *appctx) chunk_appendf(&trash, "ctr2:"); SHOW_TOT(thr, activity[thr].ctr2); #endif - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &trash) == -1) { chunk_reset(&trash); chunk_printf(&trash, "[output too large, cannot dump]\n"); - cs_rx_room_blk(cs); } #undef SHOW_AVG @@ -1567,7 +1562,6 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx) { struct show_sock_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx)); struct bind_conf *bind_conf = ctx->bind_conf; - struct stconn *cs = appctx_cs(appctx); if (!global.cli_fe) goto done; @@ -1576,7 +1570,7 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx) if (!bind_conf) { /* first call */ - if (ci_putstr(cs_ic(cs), "# socket lvl processes\n") == -1) + if (applet_putstr(appctx, "# socket lvl processes\n") == -1) goto full; bind_conf = LIST_ELEM(global.cli_fe->conf.bind.n, typeof(bind_conf), by_fe); } @@ -1624,7 +1618,7 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx) chunk_appendf(&trash, "all\n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &trash) == -1) { ctx->bind_conf = bind_conf; ctx->listener = l; goto full; @@ -1634,7 +1628,6 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx) done: return 1; full: - cs_rx_room_blk(cs); return 0; } diff --git a/src/debug.c b/src/debug.c index 1f96d6aa9..71f6762f0 100644 --- a/src/debug.c +++ b/src/debug.c @@ -304,9 +304,8 @@ static int cli_io_handler_show_threads(struct appctx *appctx) chunk_reset(&trash); ha_thread_dump_all_to_trash(); - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &trash) == -1) { /* failed, try again */ - cs_rx_room_blk(cs); appctx->st1 = thr; return 0; } @@ -1177,8 +1176,7 @@ static int debug_iohandler_fd(struct appctx *appctx) chunk_appendf(&trash, "\n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) { ctx->start_fd = fd; ret = 0; break; @@ -1288,8 +1286,7 @@ static int debug_iohandler_memstats(struct appctx *appctx) (unsigned long)ptr->size, (unsigned long)ptr->calls, (unsigned long)(ptr->calls ? (ptr->size / ptr->calls) : 0)); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) { ctx->start = ptr; ret = 0; break; diff --git a/src/dns.c b/src/dns.c index 713008eb7..3ed68922c 100644 --- a/src/dns.c +++ b/src/dns.c @@ -544,7 +544,7 @@ static void dns_session_io_handler(struct appctx *appctx) /* put msg len into then channel */ slen = (uint16_t)msg_len; slen = htons(slen); - ci_putblk(cs_ic(cs), (char *)&slen, sizeof(slen)); + applet_putblk(appctx, (char *)&slen, sizeof(slen)); available_room -= sizeof(slen); /* backup original query id */ @@ -562,7 +562,7 @@ static void dns_session_io_handler(struct appctx *appctx) new_qid = htons(new_qid); /* put new query id into the channel */ - ci_putblk(cs_ic(cs), (char *)&new_qid, sizeof(new_qid)); + applet_putblk(appctx, (char *)&new_qid, sizeof(new_qid)); available_room -= sizeof(new_qid); /* keep query id mapping */ @@ -617,12 +617,11 @@ static void dns_session_io_handler(struct appctx *appctx) } trash.data += len; - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &trash) == -1) { /* should never happen since we * check available_room is large * enough here. */ - cs_rx_room_blk(cs); ret = 0; break; } diff --git a/src/flt_spoe.c b/src/flt_spoe.c index c745e1922..df416e754 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -1145,9 +1145,10 @@ spoe_send_frame(struct appctx *appctx, char *buf, size_t framesz) * length. */ netint = htonl(framesz); memcpy(buf, (char *)&netint, 4); - ret = ci_putblk(cs_ic(cs), buf, framesz+4); + ret = applet_putblk(appctx, buf, framesz+4); if (ret <= 0) { if ((ret == -3 && b_is_null(&cs_ic(cs)->buf)) || ret == -1) { + /* WT: is this still needed for the case ret==-3 ? */ cs_rx_room_blk(cs); return 1; /* retry */ } diff --git a/src/http_client.c b/src/http_client.c index 14140442a..3b76e36ad 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -206,8 +206,7 @@ static int hc_cli_io_handler(struct appctx *appctx) if (ctx->flags & HC_CLI_F_RES_STLINE) { chunk_appendf(trash, "%.*s %d %.*s\n", (unsigned int)istlen(hc->res.vsn), istptr(hc->res.vsn), hc->res.status, (unsigned int)istlen(hc->res.reason), istptr(hc->res.reason)); - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); ctx->flags &= ~HC_CLI_F_RES_STLINE; goto out; } @@ -220,8 +219,7 @@ static int hc_cli_io_handler(struct appctx *appctx) } if (!chunk_memcat(trash, "\r\n", 2)) goto out; - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); ctx->flags &= ~HC_CLI_F_RES_HDR; goto out; } diff --git a/src/map.c b/src/map.c index eae597d47..00185cee7 100644 --- a/src/map.c +++ b/src/map.c @@ -392,13 +392,12 @@ static int cli_io_handler_pat_list(struct appctx *appctx) chunk_appendf(&trash, "%p %s\n", elt, elt->pattern); - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &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. */ LIST_APPEND(&elt->back_refs, &ctx->bref.users); HA_SPIN_UNLOCK(PATREF_LOCK, &ctx->ref->lock); - cs_rx_room_blk(cs); return 0; } skip: @@ -417,7 +416,6 @@ static int cli_io_handler_pat_list(struct appctx *appctx) static int cli_io_handler_pats_list(struct appctx *appctx) { struct show_map_ctx *ctx = appctx->svcctx; - struct stconn *cs = appctx_cs(appctx); switch (ctx->state) { case STATE_INIT: @@ -427,10 +425,8 @@ static int cli_io_handler_pats_list(struct appctx *appctx) */ chunk_reset(&trash); chunk_appendf(&trash, "# id (file) description\n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } /* Now, we start the browsing of the references lists. * Note that the following call to LIST_ELEM returns a bad pointer. The only @@ -455,11 +451,10 @@ static int cli_io_handler_pats_list(struct appctx *appctx) ctx->ref->display, ctx->ref->curr_gen, ctx->ref->next_gen, ctx->ref->entry_cnt); - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &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. */ - cs_rx_room_blk(cs); return 0; } @@ -480,7 +475,6 @@ static int cli_io_handler_pats_list(struct appctx *appctx) static int cli_io_handler_map_lookup(struct appctx *appctx) { struct show_map_ctx *ctx = appctx->svcctx; - struct stconn *cs = appctx_cs(appctx); struct sample sample; struct pattern *pat; int match_method; @@ -576,12 +570,11 @@ static int cli_io_handler_map_lookup(struct appctx *appctx) chunk_appendf(&trash, "\n"); /* display response */ - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &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. */ HA_SPIN_UNLOCK(PATREF_LOCK, &ctx->ref->lock); - cs_rx_room_blk(cs); return 0; } diff --git a/src/mworker.c b/src/mworker.c index 698321e08..7f0f711e5 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -603,10 +603,8 @@ static int cli_io_handler_show_proc(struct appctx *appctx) - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } /* dump complete */ return 1; diff --git a/src/peers.c b/src/peers.c index 0a7a9268c..c93faf33e 100644 --- a/src/peers.c +++ b/src/peers.c @@ -3744,7 +3744,7 @@ static int cli_parse_show_peers(char **args, char *payload, struct appctx *appct * Returns 0 if the output buffer is full and needs to be called again, non-zero if not. * Dedicated to be called by cli_io_handler_show_peers() cli I/O handler. */ -static int peers_dump_head(struct buffer *msg, struct stconn *cs, struct peers *peers) +static int peers_dump_head(struct buffer *msg, struct appctx *appctx, struct peers *peers) { struct tm tm; @@ -3760,10 +3760,8 @@ static int peers_dump_head(struct buffer *msg, struct stconn *cs, struct peers * TICKS_TO_MS(1000)) : "", peers->sync_task ? peers->sync_task->calls : 0); - if (ci_putchk(cs_ic(cs), msg) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, msg) == -1) return 0; - } return 1; } @@ -3919,10 +3917,8 @@ static int peers_dump_peer(struct buffer *msg, struct stconn *cs, struct peer *p end: chunk_appendf(&trash, "\n"); - if (ci_putchk(cs_ic(cs), msg) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, msg) == -1) return 0; - } return 1; } @@ -3954,7 +3950,7 @@ static int cli_io_handler_show_peers(struct appctx *appctx) chunk_appendf(&trash, "\n"); else first_peers = 0; - if (!peers_dump_head(&trash, appctx_cs(appctx), ctx->peers)) + if (!peers_dump_head(&trash, appctx, ctx->peers)) goto out; ctx->peer = ctx->peers->remote; diff --git a/src/pool.c b/src/pool.c index 4cc098d60..a47168fb6 100644 --- a/src/pool.c +++ b/src/pool.c @@ -1011,13 +1011,9 @@ int pool_parse_debugging(const char *str, char **err) */ static int cli_io_handler_dump_pools(struct appctx *appctx) { - struct stconn *cs = appctx_cs(appctx); - dump_pools_to_trash(); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } return 1; } diff --git a/src/proxy.c b/src/proxy.c index f73760f69..92fc73014 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -2772,8 +2772,7 @@ static int dump_servers_state(struct stconn *cs) chunk_appendf(&trash, "\n"); } - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) { return 0; } } @@ -2798,10 +2797,9 @@ static int cli_io_handler_servers_state(struct appctx *appctx) "# bkname/svname bkid/svid addr port - purge_delay used_cur used_max need_est unsafe_nb safe_nb idle_lim idle_cur idle_per_thr[%d]\n", global.nbthread); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } + ctx->state = SHOW_SRV_LIST; if (!ctx->px) @@ -2828,17 +2826,15 @@ static int cli_io_handler_servers_state(struct appctx *appctx) */ static int cli_io_handler_show_backend(struct appctx *appctx) { - struct stconn *cs = appctx_cs(appctx); struct proxy *curproxy; chunk_reset(&trash); if (!appctx->svcctx) { chunk_printf(&trash, "# name\n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } + appctx->svcctx = proxies_list; } @@ -2850,10 +2846,8 @@ static int cli_io_handler_show_backend(struct appctx *appctx) continue; chunk_appendf(&trash, "%s\n", curproxy->id); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } } return 1; @@ -3164,7 +3158,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 (ci_putchk(cs_ic(cs), &trash) == -1) + if (applet_putchk(appctx, &trash) == -1) goto cant_send; ctx->px = proxies_list; @@ -3254,7 +3248,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx) chunk_appendf(&trash, " \n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) + if (applet_putchk(appctx, &trash) == -1) goto cant_send_unlock; ctx->ptr = 0; @@ -3265,7 +3259,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 (ci_putchk(cs_ic(cs), &trash) == -1) + if (applet_putchk(appctx, &trash) == -1) goto cant_send_unlock; goto next; @@ -3281,7 +3275,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx) if (newptr == ctx->ptr) goto cant_send_unlock; - if (ci_putchk(cs_ic(cs), &trash) == -1) + if (applet_putchk(appctx, &trash) == -1) goto cant_send_unlock; ctx->ptr = newptr; diff --git a/src/resolvers.c b/src/resolvers.c index 1110ef5e2..9add40bab 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -2757,14 +2757,13 @@ static int cli_parse_stat_resolvers(char **args, char *payload, struct appctx *a static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx) { struct show_resolvers_ctx *ctx = appctx->svcctx; - struct stconn *cs = appctx_cs(appctx); struct resolvers *resolvers = ctx->resolvers; struct dns_nameserver *ns; chunk_reset(&trash); if (LIST_ISEMPTY(&sec_resolvers)) { - if (ci_putstr(cs_ic(cs), "No resolvers found\n") == -1) + if (applet_putstr(appctx, "No resolvers found\n") == -1) goto full; } else { @@ -2780,7 +2779,7 @@ static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx) if (!ns) { chunk_printf(&trash, "Resolvers section %s\n", resolvers->id); - if (ci_putchk(cs_ic(cs), &trash) == -1) + if (applet_putchk(appctx, &trash) == -1) goto full; ns = LIST_ELEM(resolvers->nameservers.n, typeof(ns), list); @@ -2805,7 +2804,7 @@ static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx) chunk_appendf(&trash, " too_big: %lld\n", ns->counters->app.resolver.too_big); chunk_appendf(&trash, " truncated: %lld\n", ns->counters->app.resolver.truncated); chunk_appendf(&trash, " outdated: %lld\n", ns->counters->app.resolver.outdated); - if (ci_putchk(cs_ic(cs), &trash) == -1) + if (applet_putchk(appctx, &trash) == -1) goto full; ctx->ns = ns; } @@ -2822,7 +2821,6 @@ static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx) return 1; full: /* the output buffer is full, retry later */ - cs_rx_room_blk(cs); return 0; } diff --git a/src/ring.c b/src/ring.c index b712b5ee8..a389f5b24 100644 --- a/src/ring.c +++ b/src/ring.c @@ -357,8 +357,7 @@ int cli_io_handler_show_ring(struct appctx *appctx) trash.data += len; trash.area[trash.data++] = '\n'; - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) { ret = 0; break; } diff --git a/src/server.c b/src/server.c index 9ef8d0dec..6057b4fde 100644 --- a/src/server.c +++ b/src/server.c @@ -4315,7 +4315,6 @@ static int cli_parse_set_server(char **args, char *payload, struct appctx *appct static int cli_parse_get_weight(char **args, char *payload, struct appctx *appctx, void *private) { - struct stconn *cs = appctx_cs(appctx); struct proxy *px; struct server *sv; char *line; @@ -4337,10 +4336,8 @@ static int cli_parse_get_weight(char **args, char *payload, struct appctx *appct /* return server's effective weight at the moment */ snprintf(trash.area, trash.size, "%d (initial %d)\n", sv->uweight, sv->iweight); - if (ci_putstr(cs_ic(cs), trash.area) == -1) { - cs_rx_room_blk(cs); + if (applet_putstr(appctx, trash.area) == -1) return 0; - } return 1; } diff --git a/src/sink.c b/src/sink.c index 2ff2a66bc..94addd4e1 100644 --- a/src/sink.c +++ b/src/sink.c @@ -399,8 +399,7 @@ static void sink_forward_io_handler(struct appctx *appctx) trash.data += len; trash.area[trash.data++] = '\n'; - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) { ret = 0; break; } @@ -544,8 +543,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx) trash.data += b_getblk(buf, p + 1, msg_len, ofs + cnt); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) { ret = 0; break; } diff --git a/src/ssl_ckch.c b/src/ssl_ckch.c index b00cc51ce..505353c6f 100644 --- a/src/ssl_ckch.c +++ b/src/ssl_ckch.c @@ -1319,7 +1319,6 @@ static int cli_io_handler_show_cert(struct appctx *appctx) struct show_cert_ctx *ctx = appctx->svcctx; struct buffer *trash = alloc_trash_chunk(); struct ebmb_node *node; - struct stconn *cs = appctx_cs(appctx); struct ckch_store *ckchs; if (trash == NULL) @@ -1344,10 +1343,8 @@ static int cli_io_handler_show_cert(struct appctx *appctx) chunk_appendf(trash, "%s\n", ckchs->path); node = ebmb_next(node); - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } } ctx->cur_ckchs = NULL; @@ -1721,7 +1718,6 @@ static int ckch_store_show_ocsp_certid(struct ckch_store *ckch_store, struct buf static int cli_io_handler_show_cert_detail(struct appctx *appctx) { struct show_cert_ctx *ctx = appctx->svcctx; - struct stconn *cs = appctx_cs(appctx); struct ckch_store *ckchs = ctx->cur_ckchs; struct buffer *out = alloc_trash_chunk(); int retval = 0; @@ -1751,10 +1747,8 @@ static int cli_io_handler_show_cert_detail(struct appctx *appctx) ckch_store_show_ocsp_certid(ckchs, out); end: - if (ci_putchk(cs_ic(cs), out) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, out) == -1) goto yield; - } end_no_putchk: free_trash_chunk(out); @@ -1772,7 +1766,6 @@ static int cli_io_handler_show_cert_ocsp_detail(struct appctx *appctx) { #if ((defined SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB && !defined OPENSSL_NO_OCSP) && !defined OPENSSL_IS_BORINGSSL) struct show_cert_ctx *ctx = appctx->svcctx; - struct stconn *cs = appctx_cs(appctx); struct ckch_store *ckchs = ctx->cur_ckchs; struct buffer *out = alloc_trash_chunk(); int from_transaction = ctx->transaction; @@ -1799,10 +1792,8 @@ static int cli_io_handler_show_cert_ocsp_detail(struct appctx *appctx) goto end_no_putchk; } - if (ci_putchk(cs_ic(cs), out) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, out) == -1) goto yield; - } end_no_putchk: free_trash_chunk(out); @@ -2071,10 +2062,9 @@ static int cli_io_handler_commit_cert(struct appctx *appctx) case CERT_ST_INIT: /* This state just print the update message */ chunk_printf(trash, "Committing %s", ckchs_transaction.path); - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } + ctx->state = CERT_ST_GEN; /* fallthrough */ case CERT_ST_GEN: @@ -2146,15 +2136,13 @@ static int cli_io_handler_commit_cert(struct appctx *appctx) chunk_appendf(trash, "\n"); chunk_appendf(trash, "Success!\n"); - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); free_trash_chunk(trash); /* success: call the release function and don't come back */ return 1; yield: /* store the state */ - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); free_trash_chunk(trash); cs_rx_endp_more(cs); /* let's come back later */ return 0; /* should come back */ @@ -2163,8 +2151,7 @@ static int cli_io_handler_commit_cert(struct appctx *appctx) /* spin unlock and free are done in the release function */ if (trash) { chunk_appendf(trash, "\n%sFailed!\n", err); - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); free_trash_chunk(trash); } /* error: call the release function and don't come back */ @@ -2825,10 +2812,9 @@ static int cli_io_handler_commit_cafile_crlfile(struct appctx *appctx) default: goto error; } - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } + ctx->state = CACRL_ST_GEN; /* fallthrough */ case CACRL_ST_GEN: @@ -2936,15 +2922,13 @@ static int cli_io_handler_commit_cafile_crlfile(struct appctx *appctx) chunk_appendf(trash, "\n"); chunk_appendf(trash, "Success!\n"); - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); free_trash_chunk(trash); /* success: call the release function and don't come back */ return 1; yield: /* store the state */ - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); free_trash_chunk(trash); cs_rx_endp_more(cs); /* let's come back later */ return 0; /* should come back */ @@ -2953,8 +2937,7 @@ static int cli_io_handler_commit_cafile_crlfile(struct appctx *appctx) /* spin unlock and free are done in the release function */ if (trash) { chunk_appendf(trash, "\n%sFailed!\n", err); - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); free_trash_chunk(trash); } /* error: call the release function and don't come back */ @@ -3030,7 +3013,6 @@ static void cli_release_commit_cafile(struct appctx *appctx) static int cli_io_handler_show_cafile_detail(struct appctx *appctx) { struct show_cafile_ctx *ctx = appctx->svcctx; - struct stconn *cs = appctx_cs(appctx); struct cafile_entry *cafile_entry = ctx->cur_cafile_entry; struct buffer *out = alloc_trash_chunk(); int i = 0; @@ -3074,10 +3056,8 @@ static int cli_io_handler_show_cafile_detail(struct appctx *appctx) else if (retval) goto yield; - if (ci_putchk(cs_ic(cs), out) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, out) == -1) goto yield; - } if (!show_all) /* only need to dump one certificate */ goto end; @@ -3201,7 +3181,6 @@ static int cli_io_handler_show_cafile(struct appctx *appctx) struct show_cafile_ctx *ctx = appctx->svcctx; struct buffer *trash = alloc_trash_chunk(); struct ebmb_node *node; - struct stconn *cs = appctx_cs(appctx); struct cafile_entry *cafile_entry; if (trash == NULL) @@ -3234,10 +3213,8 @@ static int cli_io_handler_show_cafile(struct appctx *appctx) } node = ebmb_next(node); - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } } ctx->cur_cafile_entry = NULL; @@ -3717,7 +3694,6 @@ static int show_crl_detail(X509_CRL *crl, struct buffer *out) static int cli_io_handler_show_crlfile_detail(struct appctx *appctx) { struct show_crlfile_ctx *ctx = appctx->svcctx; - struct stconn *cs = appctx_cs(appctx); struct cafile_entry *cafile_entry = ctx->cafile_entry; struct buffer *out = alloc_trash_chunk(); int i; @@ -3764,10 +3740,8 @@ static int cli_io_handler_show_crlfile_detail(struct appctx *appctx) } end: - if (ci_putchk(cs_ic(cs), out) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, out) == -1) goto yield; - } end_no_putchk: free_trash_chunk(out); @@ -3852,7 +3826,6 @@ static int cli_io_handler_show_crlfile(struct appctx *appctx) struct show_crlfile_ctx *ctx = appctx->svcctx; struct buffer *trash = alloc_trash_chunk(); struct ebmb_node *node; - struct stconn *cs = appctx_cs(appctx); struct cafile_entry *cafile_entry; if (trash == NULL) @@ -3881,10 +3854,8 @@ static int cli_io_handler_show_crlfile(struct appctx *appctx) } node = ebmb_next(node); - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } } ctx->cafile_entry = NULL; diff --git a/src/ssl_crtlist.c b/src/ssl_crtlist.c index 40984358c..106648e18 100644 --- a/src/ssl_crtlist.c +++ b/src/ssl_crtlist.c @@ -913,7 +913,6 @@ static int cli_io_handler_dump_crtlist(struct appctx *appctx) { struct show_crtlist_ctx *ctx = appctx->svcctx; struct buffer *trash = alloc_trash_chunk(); - struct stconn *cs = appctx_cs(appctx); struct ebmb_node *lnode; if (trash == NULL) @@ -925,10 +924,8 @@ static int cli_io_handler_dump_crtlist(struct appctx *appctx) lnode = ebmb_first(&crtlists_tree); while (lnode) { chunk_appendf(trash, "%s\n", lnode->key); - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } lnode = ebmb_next(lnode); } free_trash_chunk(trash); @@ -945,7 +942,6 @@ static int cli_io_handler_dump_crtlist_entries(struct appctx *appctx) struct show_crtlist_ctx *ctx = appctx->svcctx; struct buffer *trash = alloc_trash_chunk(); struct crtlist *crtlist; - struct stconn *cs = appctx_cs(appctx); struct crtlist_entry *entry; if (trash == NULL) @@ -957,10 +953,8 @@ static int cli_io_handler_dump_crtlist_entries(struct appctx *appctx) if (entry == NULL) { entry = LIST_ELEM((crtlist->ord_entries).n, typeof(entry), by_crtlist); chunk_appendf(trash, "# %s\n", crtlist->node.key); - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } } list_for_each_entry_from(entry, &crtlist->ord_entries, by_crtlist) { @@ -976,10 +970,8 @@ static int cli_io_handler_dump_crtlist_entries(struct appctx *appctx) dump_crtlist_filters(trash, entry); chunk_appendf(trash, "\n"); - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } } free_trash_chunk(trash); return 1; @@ -1094,10 +1086,8 @@ static int cli_io_handler_add_crtlist(struct appctx *appctx) case ADDCRT_ST_INIT: /* This state just print the update message */ chunk_printf(trash, "Inserting certificate '%s' in crt-list '%s'", store->path, crtlist->node.key); - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } ctx->state = ADDCRT_ST_GEN; /* fallthrough */ case ADDCRT_ST_GEN: @@ -1155,15 +1145,13 @@ static int cli_io_handler_add_crtlist(struct appctx *appctx) if (errcode & ERR_WARN) chunk_appendf(trash, "%s", err); chunk_appendf(trash, "Success!\n"); - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); free_trash_chunk(trash); /* success: call the release function and don't come back */ return 1; yield: /* store the state */ - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); free_trash_chunk(trash); cs_rx_endp_more(cs); /* let's come back later */ return 0; /* should come back */ @@ -1172,8 +1160,7 @@ static int cli_io_handler_add_crtlist(struct appctx *appctx) /* spin unlock and free are done in the release function */ if (trash) { chunk_appendf(trash, "\n%sFailed!\n", err); - if (ci_putchk(cs_ic(cs), trash) == -1) - cs_rx_room_blk(cs); + applet_putchk(appctx, trash); free_trash_chunk(trash); } /* error: call the release function and don't come back */ diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 6578e91f4..ee73566ec 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -7259,7 +7259,6 @@ struct tls_keys_ref *tlskeys_ref_lookup_ref(const char *reference) static int cli_io_handler_tlskeys_files(struct appctx *appctx) { struct show_keys_ctx *ctx = appctx->svcctx; - struct stconn *cs = appctx_cs(appctx); switch (ctx->state) { case SHOW_KEYS_INIT: @@ -7274,10 +7273,8 @@ static int cli_io_handler_tlskeys_files(struct appctx *appctx) else chunk_appendf(&trash, "# id (file)\n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } /* Now, we start the browsing of the references lists. * Note that the following call to LIST_ELEM return bad pointer. The only @@ -7330,12 +7327,11 @@ static int cli_io_handler_tlskeys_files(struct appctx *appctx) chunk_appendf(&trash, "%d.%d \n", ref->unique_id, ctx->next_index); } - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &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. */ HA_RWLOCK_RDUNLOCK(TLSKEYS_REF_LOCK, &ref->lock); - cs_rx_room_blk(cs); return 0; } ctx->next_index++; @@ -7343,11 +7339,10 @@ static int cli_io_handler_tlskeys_files(struct appctx *appctx) HA_RWLOCK_RDUNLOCK(TLSKEYS_REF_LOCK, &ref->lock); ctx->next_index = 0; } - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &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. */ - cs_rx_room_blk(cs); return 0; } @@ -7538,7 +7533,6 @@ static int cli_io_handler_show_ocspresponse(struct appctx *appctx) struct buffer *trash = alloc_trash_chunk(); struct buffer *tmp = NULL; struct ebmb_node *node; - struct stconn *cs = appctx_cs(appctx); struct certificate_ocsp *ocsp = NULL; BIO *bio = NULL; int write = -1; @@ -7593,10 +7587,8 @@ static int cli_io_handler_show_ocspresponse(struct appctx *appctx) chunk_appendf(trash, "%s\n", tmp->area); node = ebmb_next(node); - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } } end: @@ -7674,7 +7666,6 @@ static void ssl_provider_clear_name_list(struct list *provider_names) static int cli_io_handler_show_providers(struct appctx *appctx) { struct buffer *trash = get_trash_chunk(); - struct stconn *cs = appctx_cs(appctx); struct list provider_names; struct provider_name *name; @@ -7690,10 +7681,8 @@ static int cli_io_handler_show_providers(struct appctx *appctx) ssl_provider_clear_name_list(&provider_names); - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } return 1; @@ -7805,7 +7794,6 @@ static int cli_io_handler_show_ocspresponse_detail(struct appctx *appctx) { struct buffer *trash = alloc_trash_chunk(); struct certificate_ocsp *ocsp = appctx->svcctx; - struct stconn *cs = appctx_cs(appctx); if (trash == NULL) return 1; @@ -7815,10 +7803,8 @@ static int cli_io_handler_show_ocspresponse_detail(struct appctx *appctx) return 1; } - if (ci_putchk(cs_ic(cs), trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, trash) == -1) goto yield; - } appctx->svcctx = NULL; if (trash) diff --git a/src/stats.c b/src/stats.c index 9d012bf90..ce6e614ee 100644 --- a/src/stats.c +++ b/src/stats.c @@ -4565,10 +4565,8 @@ static int stats_dump_info_to_buffer(struct stconn *cs) else stats_dump_info_fields(&trash, info, ctx->flags); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } return 1; } @@ -4787,16 +4785,14 @@ static void stats_dump_json_schema(struct buffer *out) * It returns 0 as long as it does not complete, non-zero upon completion. * No state is used. */ -static int stats_dump_json_schema_to_buffer(struct stconn *cs) +static int stats_dump_json_schema_to_buffer(struct appctx *appctx) { chunk_reset(&trash); stats_dump_json_schema(&trash); - if (ci_putchk(cs_ic(cs), &trash) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, &trash) == -1) return 0; - } return 1; } @@ -5017,7 +5013,7 @@ static int cli_io_handler_dump_stat(struct appctx *appctx) static int cli_io_handler_dump_json_schema(struct appctx *appctx) { - return stats_dump_json_schema_to_buffer(appctx_cs(appctx)); + return stats_dump_json_schema_to_buffer(appctx); } int stats_allocate_proxy_counters_internal(struct extra_counters **counters, diff --git a/src/stick_table.c b/src/stick_table.c index 8c69dbe89..186181f51 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -4239,10 +4239,10 @@ enum { * and needs to be called again, otherwise non-zero. */ static int table_dump_head_to_buffer(struct buffer *msg, - struct stconn *cs, + struct appctx *appctx, struct stktable *t, struct stktable *target) { - struct stream *s = __cs_strm(cs); + struct stream *s = __cs_strm(appctx_cs(appctx)); chunk_appendf(msg, "# table: %s, type: %s, size:%d, used:%d\n", t->id, stktable_types[t->type].kw, t->size, t->current); @@ -4252,10 +4252,8 @@ static int table_dump_head_to_buffer(struct buffer *msg, 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 (ci_putchk(cs_ic(cs), msg) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, msg) == -1) return 0; - } return 1; } @@ -4265,7 +4263,7 @@ static int table_dump_head_to_buffer(struct buffer *msg, * and needs to be called again, otherwise non-zero. */ static int table_dump_entry_to_buffer(struct buffer *msg, - struct stconn *cs, + struct appctx *appctx, struct stktable *t, struct stksess *entry) { int dt; @@ -4379,10 +4377,8 @@ static int table_dump_entry_to_buffer(struct buffer *msg, } chunk_appendf(msg, "\n"); - if (ci_putchk(cs_ic(cs), msg) == -1) { - cs_rx_room_blk(cs); + if (applet_putchk(appctx, msg) == -1) return 0; - } return 1; } @@ -4408,7 +4404,6 @@ struct show_table_ctx { */ static int table_process_entry_per_key(struct appctx *appctx, char **args) { - struct stconn *cs = appctx_cs(appctx); struct show_table_ctx *ctx = appctx->svcctx; struct stktable *t = ctx->target; struct stksess *ts; @@ -4475,12 +4470,12 @@ static int table_process_entry_per_key(struct appctx *appctx, char **args) if (!ts) return 1; chunk_reset(&trash); - if (!table_dump_head_to_buffer(&trash, cs, t, t)) { + if (!table_dump_head_to_buffer(&trash, appctx, t, t)) { stktable_release(t, ts); return 0; } HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock); - if (!table_dump_entry_to_buffer(&trash, cs, t, ts)) { + if (!table_dump_entry_to_buffer(&trash, appctx, t, ts)) { HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock); stktable_release(t, ts); return 0; @@ -4706,7 +4701,7 @@ static int cli_io_handler_table(struct appctx *appctx) } if (ctx->t->size) { - if (show && !table_dump_head_to_buffer(&trash, cs, ctx->t, ctx->target)) + if (show && !table_dump_head_to_buffer(&trash, appctx, ctx->t, ctx->target)) return 0; if (ctx->target && @@ -4782,7 +4777,7 @@ static int cli_io_handler_table(struct appctx *appctx) } if (show && !skip_entry && - !table_dump_entry_to_buffer(&trash, cs, ctx->t, ctx->entry)) { + !table_dump_entry_to_buffer(&trash, appctx, ctx->t, ctx->entry)) { HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ctx->entry->lock); return 0; } diff --git a/src/stream.c b/src/stream.c index 99809ba62..5e0fd5802 100644 --- a/src/stream.c +++ b/src/stream.c @@ -3166,7 +3166,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *cs, struct stream *strm if (ctx->section > 0 && ctx->uid != strm->uniq_id) { /* stream changed, no need to go any further */ chunk_appendf(&trash, " *** session terminated while we were watching it ***\n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) + if (applet_putchk(appctx, &trash) == -1) goto full; goto done; } @@ -3475,7 +3475,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *cs, struct stream *strm chunk_appendf(&trash, " current_rule=\"%s\" [%s:%d]\n", rule->kw->kw, rule->conf.file, rule->conf.line); } - if (ci_putchk(cs_ic(cs), &trash) == -1) + if (applet_putchk(appctx, &trash) == -1) goto full; /* use other states to dump the contents */ @@ -3707,7 +3707,7 @@ static int cli_io_handler_dump_sess(struct appctx *appctx) chunk_appendf(&trash, "\n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) { + if (applet_putchk(appctx, &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. */ @@ -3726,7 +3726,7 @@ static int cli_io_handler_dump_sess(struct appctx *appctx) else chunk_appendf(&trash, "Session not found.\n"); - if (ci_putchk(cs_ic(cs), &trash) == -1) + if (applet_putchk(appctx, &trash) == -1) goto full; ctx->target = NULL; @@ -3739,7 +3739,6 @@ static int cli_io_handler_dump_sess(struct appctx *appctx) return 1; full: thread_release(); - cs_rx_room_blk(cs); return 0; }