}
}
+static void
+ccf_config_reload(struct cli *cli, const char * const *av, void *priv)
+{
+ char *t;
+ struct vcls *vcl, *vcl_discard;
+ (void)av;
+ (void)priv;
+ ASSERT_CLI();
+
+ asprintf(&t, "vcltmp-%d", random());
+ if (VCL_Load(av[3], t, cli))
+ cli_result(cli, CLIS_PARAM);
+
+ vcl = vcl_find(t);
+ vcl_discard = vcl_find(av[2]);
+ REPLACE(vcl->name, av[2]);
+
+ Lck_Lock(&vcl_mtx);
+ vcl_active = vcl;
+ Lck_Unlock(&vcl_mtx);
+
+ VSL_stats->n_vcl_discard++;
+ VSL_stats->n_vcl_avail--;
+ vcl_discard->conf->discard = 1;
+
+ if (vcl_discard->conf->busy == 0)
+ VCL_Nuke(vcl_discard);
+
+ return;
+}
+
static void
ccf_config_load(struct cli *cli, const char * const *av, void *priv)
{
static struct cli_proto vcl_cmds[] = {
{ CLI_VCL_LOAD, ccf_config_load },
+ { CLI_VCL_RELOAD, ccf_config_reload },
{ CLI_VCL_LIST, ccf_config_list },
{ CLI_VCL_DISCARD, ccf_config_discard },
{ CLI_VCL_USE, ccf_config_use },
{ CLI_SERVER_STOP, mcf_server_startstop, cli_proto },
{ CLI_STATS, mcf_stats, NULL },
{ CLI_VCL_LOAD, mcf_config_load, NULL },
+ { CLI_VCL_RELOAD, mcf_config_reload, NULL },
{ CLI_VCL_INLINE, mcf_config_inline, NULL },
{ CLI_VCL_USE, mcf_config_use, NULL },
{ CLI_VCL_DISCARD, mcf_config_discard, NULL },
/* mgt_vcc.c */
cli_func_t mcf_config_load;
+cli_func_t mcf_config_reload;
cli_func_t mcf_config_inline;
cli_func_t mcf_config_use;
cli_func_t mcf_config_discard;
free(p);
}
+void
+mcf_config_reload(struct cli *cli, const char *const *av, void *priv)
+{
+ char *vf;
+ struct vsb *sb;
+ unsigned status;
+ char *p = NULL;
+ struct vclprog *vp;
+ int active;
+
+ vp = mgt_vcc_byname(av[2]);
+ if (vp == NULL) {
+ cli_out(cli, "No VCL program named %s, use vcl.load", av[2]);
+ cli_result(cli, CLIS_PARAM);
+ return;
+ }
+
+ sb = vsb_newauto();
+ XXXAN(sb);
+ vf = mgt_VccCompileFile(sb, av[3], 0, -1);
+ vsb_finish(sb);
+ AZ(vsb_overflowed(sb));
+ if (vsb_len(sb) > 0)
+ cli_out(cli, "%s", vsb_data(sb));
+ vsb_delete(sb);
+ if (vf == NULL) {
+ cli_out(cli, "VCL compilation failed");
+ cli_result(cli, CLIS_PARAM);
+ return;
+ }
+
+ if (child_pid >= 0 &&
+ mgt_cli_askchild(&status, &p, "vcl.reload %s %s\n", av[2], vf)) {
+ cli_result(cli, status);
+ cli_out(cli, "%s", p);
+ } else {
+ active = vp->active;
+ mgt_vcc_del(vp);
+ vp = mgt_vcc_add(av[2], vf);
+ vp->active = active;
+ }
+ cli_out(cli, "VCL %s reloaded.", av[2]);
+ free(p);
+}
+
void
mcf_config_load(struct cli *cli, const char * const *av, void *priv)
{
"\tCompile and load the VCL file under the name provided.", \
2, 2
+#define CLI_VCL_RELOAD \
+ "vcl.reload", \
+ "vcl.reload <configname> <filename>", \
+ "\tLoad the VCL file under the name provided, discarding the old VCL", \
+ 2, 2
+
#define CLI_VCL_INLINE \
"vcl.inline", \
"vcl.inline <configname> <quoted_VCLstring>", \