X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flogin%2Flogind-utmp.c;h=4fe5ff0144f2caf3b62e263ca907bf1feec72f80;hp=d959a4a45496959922e184da5349180823b39fbd;hb=f3f6ae7c983865ea37e8ddfbd676586e55280f1e;hpb=b4f4684f3a95c915491cd7845911ecdf2622b2c2 diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c index d959a4a45..4fe5ff014 100644 --- a/src/login/logind-utmp.c +++ b/src/login/logind-utmp.c @@ -29,7 +29,7 @@ #include "bus-common-errors.h" #include "bus-error.h" #include "bus-util.h" -#include "formats-util.h" +#include "format-util.h" #include "logind.h" //#include "special.h" #include "strv.h" @@ -136,10 +136,18 @@ static int wall_message_timeout_handler( int manager_setup_wall_message_timer(Manager *m) { usec_t n, elapse; +#if 1 /// let's fix double wall messages in elogind - they suck. + usec_t left; +#endif // 1 int r; assert(m); +#if 1 /// Make elogind more aware of the possibility to disable wall messages + /* Do not do anything if wall messages aren't enabled */ + if (!m->enable_wall_messages) + return 0; +#endif // 1 n = now(CLOCK_REALTIME); elapse = m->scheduled_shutdown_timeout; @@ -153,6 +161,7 @@ int manager_setup_wall_message_timer(Manager *m) { if (elapse < n) return 0; +#if 0 /// let's fix double wall messages in elogind - they suck. /* Warn immediately if less than 15 minutes are left */ if (elapse - n < 15 * USEC_PER_MINUTE) { r = warn_wall(m, n); @@ -163,6 +172,23 @@ int manager_setup_wall_message_timer(Manager *m) { elapse = when_wall(n, elapse); if (elapse == 0) return 0; +#else + left = elapse - n; + elapse = when_wall(n, elapse); + + /* Warn immediately if less than 15 minutes are left, but not if + * there aren't more than three seconds to the next timeout. */ + if ( (left < 15 * USEC_PER_MINUTE) + && (elapse > 3 * USEC_PER_SEC) ) { + r = warn_wall(m, n); + if (r == 0) + return 0; + } + + /* If the next timeout is within on second, delay it by 3 seconds */ + if (USEC_PER_SEC > elapse) + elapse = 3 * USEC_PER_SEC; +#endif // 0 if (m->wall_message_timeout_source) { r = sd_event_source_set_time(m->wall_message_timeout_source, n + elapse);