flux-core icon indicating copy to clipboard operation
flux-core copied to clipboard

libflux: ability to debug if watcher started / stopped

Open chu11 opened this issue 3 years ago • 2 comments

A few times I've been hit by bugs / issues where it would be convenient to know if a watcher is presently started / stopped. So I end up setting flags to debug the situation.

It would be convenient to add this to libflux/reactor (perhaps in a private api?). Something like:

bool flux_watcher_is_started (flux_watcher_t *w);

internally a maintained flag set / unset when the watcher is started / stopped is probably all that is needed.

chu11 avatar Feb 24 '22 17:02 chu11

Possibly we can just wrap ev_is_active()?

garlick avatar Feb 24 '22 17:02 garlick

from discussion in #4173, proper implementation will probably be

I would think you could add a new is_active function pointer to struct flux_watcher_ops, then implement a callback for each watcher. The ones that are just wrapping ev watchers would just call ev_is_active() on the data member like the way start and stop call ev_io_stop() and ev_io_start(). That's as far as I got thinking about it - presumably the "compound watchers" (made up of multiple ev watchers) would need a custom callback that might do more inside...

above is from @garlick

Perhaps a middle ground technique could possibly be

bool flux_watcher_is_active()
{
    if (ops.is_active)
      return ops.is_active();
    else
        /* do flag stuff */
}

although that's TBD.

Since this is primarily a debugging technique, a lot of work and testing to implement. Implement when it is truly needed.

chu11 avatar Mar 02 '22 17:03 chu11