Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
garlick committed Dec 21, 2024
1 parent 94dcea6 commit 5d35662
Showing 1 changed file with 70 additions and 88 deletions.
158 changes: 70 additions & 88 deletions src/common/libflux/watcher_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,20 @@ static void fdwatcher_start (flux_watcher_t *w)
{
struct fdwatcher *fdw = watcher_get_data (w);
struct ev_loop *loop = watcher_get_ev (w);
if (!ev_is_active (&fdw->evw)) {
ev_io_start (loop, &fdw->evw);
if (!flux_watcher_is_referenced (w))
bool active = ev_is_active (&fdw->evw);
ev_io_start (loop, &fdw->evw);
if (!active && !flux_watcher_is_referenced (w))
ev_unref (loop);
}
}

static void fdwatcher_stop (flux_watcher_t *w)
{
struct fdwatcher *fdw = watcher_get_data (w);
struct ev_loop *loop = watcher_get_ev (w);
if (ev_is_active (&fdw->evw)) {
if (!flux_watcher_is_referenced (w))
ev_ref (loop);
ev_io_stop (loop, &fdw->evw);
}
bool active = ev_is_active (&fdw->evw);
if (active && !flux_watcher_is_referenced (w))
ev_ref (loop);
ev_io_stop (loop, &fdw->evw);
}

static void fdwatcher_ref (flux_watcher_t *w)
Expand Down Expand Up @@ -186,22 +184,20 @@ static void tmwatcher_start (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct tmwatcher *tmw = watcher_get_data (w);
if (!ev_is_active (&tmw->evw)) {
ev_timer_start (loop, &tmw->evw);
if (!flux_watcher_is_referenced (w))
ev_unref (loop);
}
bool active = ev_is_active (&tmw->evw);
ev_timer_start (loop, &tmw->evw);
if (!active && !flux_watcher_is_referenced (w))
ev_unref (loop);
}

static void tmwatcher_stop (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct tmwatcher *tmw = watcher_get_data (w);
if (ev_is_active (&tmw->evw)) {
if (!flux_watcher_is_referenced (w))
ev_ref (loop);
ev_timer_stop (loop, &tmw->evw);
}
bool active = ev_is_active (&tmw->evw);
if (active && !flux_watcher_is_referenced (w))
ev_ref (loop);
ev_timer_stop (loop, &tmw->evw);
}

static void tmwatcher_ref (flux_watcher_t *w)
Expand Down Expand Up @@ -313,22 +309,20 @@ static void pdwatcher_start (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct pdwatcher *pdw = watcher_get_data (w);
if (!ev_is_active (&pdw->evw)) {
ev_periodic_start (loop, &pdw->evw);
if (!flux_watcher_is_referenced (w))
ev_unref (loop);
}
bool active = ev_is_active (&pdw->evw);
ev_periodic_start (loop, &pdw->evw);
if (!active && !flux_watcher_is_referenced (w))
ev_unref (loop);
}

static void pdwatcher_stop (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct pdwatcher *pdw = watcher_get_data (w);
if (ev_is_active (&pdw->evw)) {
if (!flux_watcher_is_referenced (w))
ev_ref (loop);
ev_periodic_stop (loop, &pdw->evw);
}
bool active = ev_is_active (&pdw->evw);
if (active && !flux_watcher_is_referenced (w))
ev_ref (loop);
ev_periodic_stop (loop, &pdw->evw);
}

static void pdwatcher_ref (flux_watcher_t *w)
Expand Down Expand Up @@ -486,22 +480,20 @@ static void prepwatcher_start (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct prepwatcher *pw = watcher_get_data (w);
if (!ev_is_active (&pw->evw)) {
ev_prepare_start (loop, &pw->evw);
if (!flux_watcher_is_referenced (w))
bool active = ev_is_active (&pw->evw);
ev_prepare_start (loop, &pw->evw);
if (!active && !flux_watcher_is_referenced (w))
ev_unref (loop);
}
}

static void prepwatcher_stop (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct prepwatcher *pw = watcher_get_data (w);
if (ev_is_active (&pw->evw)) {
if (!flux_watcher_is_referenced (w))
ev_ref (loop);
ev_prepare_stop (loop, &pw->evw);
}
bool active = ev_is_active (&pw->evw);
if (active && !flux_watcher_is_referenced (w))
ev_ref (loop);
ev_prepare_stop (loop, &pw->evw);
}

static void prepwatcher_ref (flux_watcher_t *w)
Expand Down Expand Up @@ -574,22 +566,20 @@ static void checkwatcher_start (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct checkwatcher *cw = watcher_get_data (w);
if (!ev_is_active (&cw->evw)) {
ev_check_start (loop, &cw->evw);
if (!flux_watcher_is_referenced (w))
ev_unref (loop);
}
bool active = ev_is_active (&cw->evw);
ev_check_start (loop, &cw->evw);
if (!active && !flux_watcher_is_referenced (w))
ev_unref (loop);
}

static void checkwatcher_stop (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct checkwatcher *cw = watcher_get_data (w);
if (ev_is_active (&cw->evw)) {
if (!flux_watcher_is_referenced (w))
ev_ref (loop);
ev_check_stop (loop, &cw->evw);
}
bool active = ev_is_active (&cw->evw);
if (active && !flux_watcher_is_referenced (w))
ev_ref (loop);
ev_check_stop (loop, &cw->evw);
}

static void checkwatcher_ref (flux_watcher_t *w)
Expand Down Expand Up @@ -657,22 +647,20 @@ static void idlewatcher_start (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct idlewatcher *iw = watcher_get_data (w);
if (!ev_is_active (&iw->evw)) {
ev_idle_start (loop, &iw->evw);
if (!flux_watcher_is_referenced (w))
ev_unref (loop);
}
bool active = ev_is_active (&iw->evw);
ev_idle_start (loop, &iw->evw);
if (!active && !flux_watcher_is_referenced (w))
ev_unref (loop);
}

static void idlewatcher_stop (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct idlewatcher *iw = watcher_get_data (w);
if (ev_is_active (&iw->evw)) {
if (!flux_watcher_is_referenced (w))
ev_ref (loop);
ev_idle_stop (loop, &iw->evw);
}
bool active = ev_is_active (&iw->evw);
if (active && !flux_watcher_is_referenced (w))
ev_ref (loop);
ev_idle_stop (loop, &iw->evw);
}

static void idlewatcher_ref (flux_watcher_t *w)
Expand Down Expand Up @@ -739,22 +727,20 @@ static void childwatcher_start (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct childwatcher *cw = watcher_get_data (w);
if (!ev_is_active (&cw->evw)) {
ev_child_start (loop, &cw->evw);
if (!flux_watcher_is_referenced (w))
ev_unref (loop);
}
bool active = ev_is_active (&cw->evw);
ev_child_start (loop, &cw->evw);
if (!active && !flux_watcher_is_referenced (w))
ev_unref (loop);
}

static void childwatcher_stop (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct childwatcher *cw = watcher_get_data (w);
if (ev_is_active (&cw->evw)) {
if (!flux_watcher_is_referenced (w))
ev_ref (loop);
ev_child_stop (loop, &cw->evw);
}
bool active = ev_is_active (&cw->evw);
if (active && !flux_watcher_is_referenced (w))
ev_ref (loop);
ev_child_stop (loop, &cw->evw);
}

static void childwatcher_ref (flux_watcher_t *w)
Expand Down Expand Up @@ -847,22 +833,20 @@ static void sigwatcher_start (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct sigwatcher *sw = watcher_get_data (w);
if (!ev_is_active (&sw->evw)) {
ev_signal_start (loop, &sw->evw);
if (!flux_watcher_is_referenced (w))
ev_unref (loop);
}
bool active = ev_is_active (&sw->evw);
ev_signal_start (loop, &sw->evw);
if (!active && !flux_watcher_is_referenced (w))
ev_unref (loop);
}

static void sigwatcher_stop (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct sigwatcher *sw = watcher_get_data (w);
if (ev_is_active (&sw->evw)) {
if (!flux_watcher_is_referenced (w))
ev_ref (loop);
ev_signal_stop (loop, &sw->evw);
}
bool active = ev_is_active (&sw->evw);
if (active && !flux_watcher_is_referenced (w))
ev_ref (loop);
ev_signal_stop (loop, &sw->evw);
}

static void sigwatcher_ref (flux_watcher_t *w)
Expand Down Expand Up @@ -940,22 +924,20 @@ static void statwatcher_start (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct statwatcher *sw = watcher_get_data (w);
if (!ev_is_active (&sw->evw)) {
ev_stat_start (loop, &sw->evw);
if (!flux_watcher_is_referenced (w))
ev_unref (loop);
}
bool active = ev_is_active (&sw->evw);
ev_stat_start (loop, &sw->evw);
if (!active && !flux_watcher_is_referenced (w))
ev_unref (loop);
}

static void statwatcher_stop (flux_watcher_t *w)
{
struct ev_loop *loop = watcher_get_ev (w);
struct statwatcher *sw = watcher_get_data (w);
if (ev_is_active (&sw->evw)) {
if (!flux_watcher_is_referenced (w))
ev_ref (loop);
ev_stat_stop (loop, &sw->evw);
}
bool active = ev_is_active (&sw->evw);
if (active && !flux_watcher_is_referenced (w))
ev_ref (loop);
ev_stat_stop (loop, &sw->evw);
}

static void statwatcher_ref (flux_watcher_t *w)
Expand Down

0 comments on commit 5d35662

Please sign in to comment.