Commit 109f441c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move 'delay', 'shell' and 'barrier' to a new category of "global" commands.

parent bc13919d
......@@ -29,21 +29,29 @@
/*lint -save -e525 -e539 */
CMD(barrier)
CMD(client)
CMD(delay)
CMD(err_shell)
CMD(feature)
CMD(haproxy)
CMD(logexpect)
CMD(process)
CMD(server)
CMD(setenv)
CMD(shell)
CMD(syslog)
CMD(varnish)
CMD(varnishtest)
CMD(vtest)
#undef CMD
#ifndef CMD_GLOBAL
#define CMD_GLOBAL(x)
#endif
CMD_GLOBAL(barrier)
CMD_GLOBAL(delay)
CMD_GLOBAL(shell)
#undef CMD_GLOBAL
#ifndef CMD_TOP
#define CMD_TOP(x)
#endif
CMD_TOP(client)
CMD_TOP(err_shell)
CMD_TOP(feature)
CMD_TOP(haproxy)
CMD_TOP(logexpect)
CMD_TOP(process)
CMD_TOP(server)
CMD_TOP(setenv)
CMD_TOP(syslog)
CMD_TOP(varnish)
CMD_TOP(varnishtest)
CMD_TOP(vtest)
#undef CMD_TOP
/*lint -restore */
......@@ -290,6 +290,13 @@ macro_expand(struct vtclog *vl, const char *text)
* Static checkers like Coverity may bitch about this, but we don't care.
*/
static const struct cmds global_cmds[] = {
#define CMD_GLOBAL(n) { #n, cmd_##n },
#include "cmds.h"
{ NULL, NULL }
};
void
parse_string(const char *spec, const struct cmds *cmd, void *priv,
struct vtclog *vl)
......@@ -410,6 +417,12 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv,
if (!strcmp(token_s[0], cp->name))
break;
if (cp->name == NULL) {
for (cp = global_cmds; cp->name != NULL; cp++)
if (!strcmp(token_s[0], cp->name))
break;
}
if (cp->name == NULL)
vtc_fatal(vl, "Unknown command: \"%s\"", token_s[0]);
......@@ -435,7 +448,7 @@ reset_cmds(const struct cmds *cmd)
*/
static const struct cmds cmds[] = {
#define CMD(n) { #n, cmd_##n },
#define CMD_TOP(n) { #n, cmd_##n },
#include "cmds.h"
{ NULL, NULL }
};
......
......@@ -69,7 +69,8 @@ void parse_string(const char *spec, const struct cmds *cmd, void *priv,
struct vtclog *vl);
int fail_out(void);
#define CMD(n) cmd_f cmd_##n;
#define CMD_GLOBAL(n) cmd_f cmd_##n;
#define CMD_TOP(n) cmd_f cmd_##n;
#include "cmds.h"
extern volatile sig_atomic_t vtc_error; /* Error, bail out */
......
......@@ -348,8 +348,7 @@ barrier_sync(struct barrier *b, struct vtclog *vl)
/* SECTION: barrier barrier
*
* NOTE: this can be used from the top-level as well as from client and server
* specifications.
* NOTE: This command is available everywhere commands are given.
*
* Barriers allows you to synchronize different threads to make sure events
* occur in the right order. It's even possible to use them in VCL.
......
......@@ -1659,17 +1659,6 @@ cmd_http_fatal(CMD_ARGS)
#define cmd_http_non_fatal cmd_http_fatal
/* SECTION: client-server.spec.delay
*
* delay
* Same as for the top-level delay.
*
* SECTION: client-server.spec.barrier
*
* barrier
* Same as for the top-level barrier
*/
static const char PREFACE[24] = {
0x50, 0x52, 0x49, 0x20, 0x2a, 0x20, 0x48, 0x54,
0x54, 0x50, 0x2f, 0x32, 0x2e, 0x30, 0x0d, 0x0a,
......@@ -1815,7 +1804,6 @@ cmd_http_write_body(CMD_ARGS)
*/
const struct cmds http_cmds[] = {
#define CMD(n) { #n, cmd_##n },
#define CMD_HTTP(n) { #n, cmd_http_##n },
/* session */
CMD_HTTP(accept)
......@@ -1864,13 +1852,7 @@ const struct cmds http_cmds[] = {
CMD_HTTP(expect)
CMD_HTTP(expect_close)
CMD_HTTP(expect_pattern)
/* general purpose */
CMD(barrier)
CMD(delay)
CMD(shell)
#undef CMD_HTTP
#undef CMD
{ NULL, NULL }
};
......
......@@ -2445,7 +2445,6 @@ cmd_write_body(CMD_ARGS)
* client or a server.
*/
static const struct cmds stream_cmds[] = {
#define CMD(n) { #n, cmd_##n },
#define CMD_STREAM(n) { #n, cmd_##n },
/* spec */
CMD_STREAM(expect)
......@@ -2475,14 +2474,8 @@ static const struct cmds stream_cmds[] = {
CMD_STREAM(txsettings)
CMD_STREAM(txwinup)
CMD_STREAM(write_body)
/* general purpose */
CMD(barrier)
CMD(delay)
CMD(shell)
{ NULL, NULL }
#undef CMD_STREAM
#undef CMD
};
static void *
......
......@@ -99,6 +99,8 @@ cmd_varnishtest(CMD_ARGS)
}
/* SECTION: shell shell
*
* NOTE: This command is available everywhere commands are given.
*
* Pass the string given as argument to a shell. If you have multiple
* commands to run, you can use curly brackets to describe a multi-lines
......@@ -311,13 +313,12 @@ cmd_setenv(CMD_ARGS)
}
/* SECTION: delay delay
*
* NOTE: This command is available everywhere commands are given.
*
* Sleep for the number of seconds specified in the argument. The number
* can include a fractional part, e.g. 1.5.
*/
/* SECTION: stream.spec.delay delay
*
* Same as for the top-level delay.
*/
void
cmd_delay(CMD_ARGS)
......
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