Commit 94bd4886 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

cli: New debug.shutdown.delay command

For the purpose of simulating a workload where the cache process takes
significant time to shut down.
parent 686c65b3
......@@ -48,6 +48,8 @@
#include "common/heritage.h"
#include "vcli_serve.h"
#include "vnum.h"
#include "vtim.h"
#include "vrnd.h"
#include "hash/hash_slinger.h"
......@@ -56,6 +58,7 @@ int cache_shutdown = 0;
volatile struct params *cache_param;
static pthread_mutex_t cache_vrnd_mtx;
static vtim_dur shutdown_delay = 0;
pthread_mutexattr_t mtxattr_errorcheck;
......@@ -224,6 +227,18 @@ cli_debug_xid(struct cli *cli, const char * const *av, void *priv)
VCLI_Out(cli, "XID is %u", vxid_base);
}
/*
* Artificially slow down the process shutdown.
*/
static void v_matchproto_(cli_func_t)
cli_debug_shutdown_delay(struct cli *cli, const char * const *av, void *priv)
{
(void)cli;
(void)priv;
shutdown_delay = VNUM_duration(av[2]);
}
/*
* Default to seed=1, this is the only seed value POSIXl guarantees will
* result in a reproducible random number sequence.
......@@ -241,8 +256,9 @@ cli_debug_srandom(struct cli *cli, const char * const *av, void *priv)
}
static struct cli_proto debug_cmds[] = {
{ CLICMD_DEBUG_XID, "d", cli_debug_xid },
{ CLICMD_DEBUG_SRANDOM, "d", cli_debug_srandom },
{ CLICMD_DEBUG_XID, "d", cli_debug_xid },
{ CLICMD_DEBUG_SHUTDOWN_DELAY, "d", cli_debug_shutdown_delay },
{ CLICMD_DEBUG_SRANDOM, "d", cli_debug_srandom },
{ NULL }
};
......@@ -434,6 +450,10 @@ child_main(int sigmagic, size_t altstksz)
CLI_Run();
cache_shutdown = 1;
if (shutdown_delay > 0)
VTIM_sleep(shutdown_delay);
VCA_Shutdown();
BAN_Shutdown();
EXP_Shutdown();
......
......@@ -359,6 +359,15 @@ CLI_CMD(DEBUG_REQPOOLFAIL,
"allocations will fail.",
1, 1
)
CLI_CMD(DEBUG_SHUTDOWN_DELAY,
"debug.shutdown.delay",
"debug.shutdown.delay",
"Add a delay to the child process shutdown.",
"",
1, 1
)
CLI_CMD(DEBUG_XID,
"debug.xid",
"debug.xid",
......
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