Commit 9fe43bdf authored by Andrew Wiik's avatar Andrew Wiik Committed by Reza Naghibi

Add a 'debug.reqpool.fail F__F____F_FFF' command

0ad32622Co-authored-by: 's avatarPoul-Henning Kamp <phk@FreeBSD.org>
parent e9523422
......@@ -391,6 +391,8 @@ child_main(int sigmagic, size_t altstksz)
VMOD_Init();
WRK_Init();
BAN_Compile();
VRND_SeedAll();
......
......@@ -414,6 +414,9 @@ extern struct vrt_privs cli_task_privs[1];
void VMOD_Init(void);
void VMOD_Panic(struct vsb *);
/* cache_wrk.c */
void WRK_Init(void);
/* http1/cache_http1_pipe.c */
void V1P_Init(void);
......
......@@ -58,12 +58,15 @@
#include "cache_varnishd.h"
#include "cache_pool.h"
#include "vcli_serve.h"
#include "vtim.h"
#include "hash/hash_slinger.h"
static void Pool_Work_Thread(struct pool *pp, struct worker *wrk);
static uintmax_t reqpoolfail;
/*--------------------------------------------------------------------
* Create and start a back-ground thread which as its own worker and
* session data structures;
......@@ -261,6 +264,17 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio)
AN(task->func);
assert(prio < TASK_QUEUE_END);
if (prio == TASK_QUEUE_REQ && reqpoolfail) {
retval = reqpoolfail & 1;
reqpoolfail >>= 1;
if (retval) {
VSL(SLT_Debug, 0,
"Failing due to reqpoolfail (next= 0x%jx)",
reqpoolfail);
return(retval);
}
}
Lck_Lock(&pp->mtx);
/* The common case first: Take an idle thread, do it. */
......@@ -610,3 +624,39 @@ pool_herder(void *priv)
}
return (NULL);
}
/*--------------------------------------------------------------------
* Debugging aids
*/
static void v_matchproto_(cli_func_t)
debug_reqpoolfail(struct cli *cli, const char * const *av, void *priv)
{
uintmax_t u = 1;
const char *p;
(void)priv;
(void)cli;
reqpoolfail = 0;
for (p = av[2]; *p != '\0'; p++) {
if (*p == 'F' || *p == 'f')
reqpoolfail |= u;
u <<= 1;
}
}
static struct cli_proto debug_cmds[] = {
{ CLICMD_DEBUG_REQPOOLFAIL, "d", debug_reqpoolfail },
{ NULL }
};
/*--------------------------------------------------------------------
*
*/
void
WRK_Init(void)
{
CLI_AddFuncs(debug_cmds);
}
......@@ -278,6 +278,16 @@ CLI_CMD(DEBUG_FRAGFETCH,
1, 1
)
CLI_CMD(DEBUG_REQPOOLFAIL,
"debug.reqpool.fail",
"debug.reqpool.fail",
"Schedule req-pool failures.",
"The argument is read L-R and 'f' means fail:\n\n"
"\tparam.set debug.reqpoolfail F__F\n\n"
"Means that the frist and the third attempted allocation will fail",
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