MEDIUM: stream/debug: force a crash if a stream spins over itself forever

If a stream is caught spinning over itself at more than 100000 loops per
second and for more than one second, the process will be aborted and the
offender reported on the console and logs. Typical figures usually are just
a few tens to hundreds per second over a very short time so there is a huge
margin here. Using even higher values could also work but there is the risk
of not being able to catch offenders if multiple ones start to bug at the
same time and share the load. This code should ideally be disabled for
stable releases, though in theory nothing should ever trigger it.
This commit is contained in:
Willy Tarreau 2019-04-25 19:15:20 +02:00
parent dcb0e1d37d
commit 3d07a16f14

View File

@ -1711,6 +1711,7 @@ struct task *process_stream(struct task *t, void *context, unsigned short state)
unsigned int req_ana_back;
struct channel *req, *res;
struct stream_interface *si_f, *si_b;
unsigned int rate;
activity[tid].stream++;
@ -1725,7 +1726,10 @@ struct task *process_stream(struct task *t, void *context, unsigned short state)
si_sync_recv(si_b);
redo:
update_freq_ctr(&s->call_rate, 1);
rate = update_freq_ctr(&s->call_rate, 1);
if (rate >= 100000 && s->call_rate.prev_ctr) { // make sure to wait at least a full second
stream_dump_and_crash(&s->obj_type, read_freq_ctr(&s->call_rate));
}
//DPRINTF(stderr, "%s:%d: cs=%d ss=%d(%d) rqf=0x%08x rpf=0x%08x\n", __FUNCTION__, __LINE__,
// si_f->state, si_b->state, si_b->err_type, req->flags, res->flags);