https://bugzilla.wikimedia.org/show_bug.cgi?id=45684

--- Comment #5 from Tim Starling <[email protected]> ---
(In reply to comment #2)
> Maybe it would be possible to record the CPU usage delta by calling
> timer_gettime() at the start and end of the getExpandedArgument() call. But
> translating that discount into delayed signal delivery would need to be done
> with care, to avoid the same resolution issue when calling timer_settime().

Brad, can you look at this? I'm not sure exactly what the interface would look
like -- maybe a simple LuaSandbox::pauseUsageTimer() and
LuaSandbox::resumeUsageTimer(), with most of the logic written in C.

luasandbox_update_usage() could adjust the returned usage based on the
accumulated "pause" time. If the timeout timer expires with the pause counter
non-zero, it would be restarted with an interval equal to the pause counter.

If the timeout timer expires during "pause", we will have to wait for the hook
function to run before we can re-arm it, since timer_settime() is not
signal-safe. The amount to add to the pause counter would be the time between
the pause and the signal, minus the time between the unpause and the hook
execution. See attached diagram.

It is possible to call timer_gettime() from the signal handler, so it's
possible to do this calculation.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to