X-Git-Url: https://git.opensvc.com/gitweb.cgi?p=multipath-tools%2F.git;a=blobdiff_plain;f=multipathd%2Fmain.c;h=f766d647bb88e7388a87de83f73dfd21229a9f06;hp=33db6a4693628887226b1a26345e4c33f009d782;hb=88ddca5772f74a2e44c2d4fef947bc8fb7125c7b;hpb=0231ec20a448f999218719b240e761f7ae99ed4e diff --git a/multipathd/main.c b/multipathd/main.c index 33db6a46..f766d647 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -161,15 +161,27 @@ sd_notify_status(void) case DAEMON_CONFIGURE: return "STATUS=configure"; case DAEMON_IDLE: - return "STATUS=idle"; case DAEMON_RUNNING: - return "STATUS=running"; + return "STATUS=up"; case DAEMON_SHUTDOWN: return "STATUS=shutdown"; } return NULL; } +static void do_sd_notify(enum daemon_status old_state) +{ + /* + * Checkerloop switches back and forth between idle and running state. + * No need to tell systemd each time. + * These notifications cause a lot of overhead on dbus. + */ + if ((running_state == DAEMON_IDLE || running_state == DAEMON_RUNNING) && + (old_state == DAEMON_IDLE || old_state == DAEMON_RUNNING)) + return; + sd_notify(0, sd_notify_status()); +} + static void config_cleanup(void *arg) { pthread_mutex_unlock(&config_lock); @@ -179,10 +191,12 @@ void post_config_state(enum daemon_status state) { pthread_mutex_lock(&config_lock); if (state != running_state) { + enum daemon_status old_state = running_state; + running_state = state; pthread_cond_broadcast(&config_cond); #ifdef USE_SYSTEMD - sd_notify(0, sd_notify_status()); + do_sd_notify(old_state); #endif } pthread_mutex_unlock(&config_lock); @@ -195,6 +209,8 @@ int set_config_state(enum daemon_status state) pthread_cleanup_push(config_cleanup, NULL); pthread_mutex_lock(&config_lock); if (running_state != state) { + enum daemon_status old_state = running_state; + if (running_state != DAEMON_IDLE) { struct timespec ts; @@ -207,7 +223,7 @@ int set_config_state(enum daemon_status state) running_state = state; pthread_cond_broadcast(&config_cond); #ifdef USE_SYSTEMD - sd_notify(0, sd_notify_status()); + do_sd_notify(old_state); #endif } }