Commit 007a381d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a delay command, it takes second.fraction and uses usleep()

below 100s and sleep() over.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2712 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 906b4234
......@@ -249,7 +249,29 @@ cmd_test(char **av, void *priv)
/**********************************************************************
* Execute a file
* Dump command arguments
*/
void
cmd_delay(char **av, void *priv)
{
double f;
(void)priv;
if (av == NULL)
return;
AN(av[1]);
AZ(av[2]);
f = strtod(av[1], NULL);
if (f > 100.) {
sleep((int)f);
} else {
usleep((int)(f * 1e6));
}
}
/**********************************************************************
* Dump command arguments
*/
void
......@@ -263,11 +285,16 @@ cmd_dump(char **av, void *priv)
printf("\t<%s>\n", *av++);
}
/**********************************************************************
* Execute a file
*/
static struct cmds cmds[] = {
{ "server", cmd_server },
{ "client", cmd_client },
{ "stats", cmd_stats },
{ "varnish", cmd_varnish },
{ "delay", cmd_delay },
{ "test", cmd_test },
{ NULL, NULL }
};
......@@ -294,6 +321,7 @@ main(int argc, char **argv)
int ch;
setbuf(stdout, NULL);
setbuf(stderr, NULL);
while ((ch = getopt(argc, argv, "")) != -1) {
switch (ch) {
case '?':
......
......@@ -36,6 +36,8 @@ struct cmds {
void parse_string(char *buf, const struct cmds *cmd, void *priv);
void cmd_dump(char **av, void *priv);
void cmd_delay(char **av, void *priv);
void cmd_server(char **av, void *priv);
void cmd_client(char **av, void *priv);
void cmd_vcl(char **av, void *priv);
......
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