[DTrace-devel] [PATCH] consume: fix epoll_wait() timeut

Kris Van Hees kris.van.hees at oracle.com
Fri Mar 3 06:06:21 UTC 2023


If swotchrate was set to a value other than zero, we could end up with
a double delay between two buffer polls because first the switchrate
value was used to enforce a delay between two consecutive polls *and*
we would pass the switchrate value to epoll_wait() as timeout.

Setting the interval to 0 after switchrate has been used to space the
polls ensures that the epoll_wait() won't cause any further delay.

If switchrate is not used (it is 0), then we still need the interval
to be 1s to provide a timeout for epoll_wait().

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 libdtrace/dt_consume.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libdtrace/dt_consume.c b/libdtrace/dt_consume.c
index d628ff21..0f3c0691 100644
--- a/libdtrace/dt_consume.c
+++ b/libdtrace/dt_consume.c
@@ -3032,6 +3032,8 @@ dtrace_consume(dtrace_hdl_t *dtp, FILE *fp, dtrace_consume_probe_f *pf,
 			dtp->dt_lastswitch += interval;
 		} else
 			dtp->dt_lastswitch = now;
+
+		interval  = 0;
 	} else
 		interval = NANOSEC;			/* 1s */
 
-- 
2.39.1




More information about the DTrace-devel mailing list