[master] 9857918 Add VCLI_Overflow() so we can stop rendering bans when the CLI output buffer is full.

Poul-Henning Kamp phk at varnish-cache.org
Tue Nov 15 20:52:48 CET 2011


commit 9857918cf7916d860fe3f4358960467359c6fd5c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Nov 14 11:26:44 2011 +0000

    Add VCLI_Overflow() so we can stop rendering bans when the CLI
    output buffer is full.

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 768e631..ca2b616 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -1071,6 +1071,8 @@ ccf_ban_list(struct cli *cli, const char * const *av, void *priv)
 		    b->flags & BAN_F_GONE ? "G" : " ");
 		ban_render(cli, b->spec);
 		VCLI_Out(cli, "\n");
+		if (VCLI_Overflow(cli))
+			break;
 		if (cache_param->diag_bitmap & 0x80000) {
 			Lck_Lock(&ban_mtx);
 			struct objcore *oc;
diff --git a/include/vcli_priv.h b/include/vcli_priv.h
index 60d6d69..a265d2e 100644
--- a/include/vcli_priv.h
+++ b/include/vcli_priv.h
@@ -52,6 +52,7 @@ struct cli_proto {
 };
 
 /* The implementation must provide these functions */
+int VCLI_Overflow(struct cli *cli);
 void VCLI_Out(struct cli *cli, const char *fmt, ...);
 void VCLI_Quote(struct cli *cli, const char *str);
 void VCLI_SetResult(struct cli *cli, unsigned r);
diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c
index 7b09bdb..aa5fd63 100644
--- a/lib/libvarnish/cli_common.c
+++ b/lib/libvarnish/cli_common.c
@@ -70,6 +70,17 @@ VCLI_Out(struct cli *cli, const char *fmt, ...)
 }
 
 /*lint -e{818} cli could be const */
+int
+VCLI_Overflow(struct cli *cli)
+{
+	CHECK_OBJ_NOTNULL(cli, CLI_MAGIC);
+	if (cli->result == CLIS_TRUNCATED ||
+	    VSB_len(cli->sb) >= *cli->limit)
+		return (1);
+	return (0);
+}
+
+/*lint -e{818} cli could be const */
 void
 VCLI_Quote(struct cli *cli, const char *s)
 {



More information about the varnish-commit mailing list