Commit 4b87b41b authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add the unadultered cli command to struct cli, and make the default

"before" callback arg be the cli struct like the "after" callback.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4471 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 5c279deb
...@@ -96,8 +96,10 @@ CLI_AddFuncs(enum cli_set_e which, struct cli_proto *p) ...@@ -96,8 +96,10 @@ CLI_AddFuncs(enum cli_set_e which, struct cli_proto *p)
static void static void
cli_cb_before(void *priv) cli_cb_before(void *priv)
{ {
struct cli *cli;
VSL(SLT_CLI, 0, "Rd %s", priv); cli = priv;
VSL(SLT_CLI, 0, "Rd %s", cli->cmd);
VCL_Poll(); VCL_Poll();
VBE_Poll(); VBE_Poll();
Lck_Lock(&cli_mtx); Lck_Lock(&cli_mtx);
......
...@@ -34,6 +34,7 @@ struct cli { ...@@ -34,6 +34,7 @@ struct cli {
struct vsb *sb; struct vsb *sb;
enum cli_status_e result; enum cli_status_e result;
void *priv; void *priv;
const char *cmd;
}; };
int cli_writeres(int fd, const struct cli *cli); int cli_writeres(int fd, const struct cli *cli);
......
...@@ -92,8 +92,9 @@ cls_vlu(void *priv, const char *p) ...@@ -92,8 +92,9 @@ cls_vlu(void *priv, const char *p)
cs = cfd->cls; cs = cfd->cls;
CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); CHECK_OBJ_NOTNULL(cs, CLS_MAGIC);
cfd->cli->cmd = p;
if (cs->before != NULL) if (cs->before != NULL)
cs->before(cs->priv != NULL ? cs->priv : (void*)(uintptr_t)p); cs->before(cs->priv != NULL ? cs->priv : cfd->cli);
VTAILQ_FOREACH(cfn, &cs->funcs, list) { VTAILQ_FOREACH(cfn, &cs->funcs, list) {
vsb_clear(cfd->cli->sb); vsb_clear(cfd->cli->sb);
cfd->cli->result = CLIS_OK; cfd->cli->result = CLIS_OK;
...@@ -107,6 +108,7 @@ cls_vlu(void *priv, const char *p) ...@@ -107,6 +108,7 @@ cls_vlu(void *priv, const char *p)
cs->after(cs->priv != NULL ? cs->priv : cfd->cli); cs->after(cs->priv != NULL ? cs->priv : cfd->cli);
if (cli_writeres(cfd->fdo, cfd->cli) || cfd->cli->result == CLIS_CLOSE) if (cli_writeres(cfd->fdo, cfd->cli) || cfd->cli->result == CLIS_CLOSE)
return (1); return (1);
cfd->cli->cmd = NULL;
return (0); return (0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment