Git commit 3b3f247f28b25e61a9d1820ea25f3c4a2b699a1d by Oswald Buddenhagen. Committed on 28/03/2014 at 16:52. Pushed by ossi into branch 'KDE/4.11'. fix resumption from console mode when monotonic clock is in use BUG: 312947 FIXED-IN: 4.11.8 M +14 -3 kdm/backend/dm.c M +7 -3 kdm/backend/dm.h http://commits.kde.org/kde-workspace/3b3f247f28b25e61a9d1820ea25f3c4a2b699a= 1d diff --git a/kdm/backend/dm.c b/kdm/backend/dm.c index e0f1366..77a2ef7 100644 --- a/kdm/backend/dm.c +++ b/kdm/backend/dm.c @@ -74,8 +74,11 @@ static int stopping; SdRec sdRec =3D { 0, 0, 0, TO_INF, TO_INF, 0, 0, 0 }; = time_t now; -#ifndef nowMonotonic +#if (_POSIX_MONOTONIC_CLOCK >=3D 0) +time_t nowWallDelta; +# ifndef nowMonotonic int nowMonotonic; +# endif #endif = #if KDM_LIBEXEC_STRIP !=3D -1 @@ -339,6 +342,11 @@ updateNow(void) clock_gettime(CLOCK_MONOTONIC, &ts); /* Linux' monotonic clock starts at zero, but this is assumed to m= ean "long ago". */ now =3D ts.tv_sec + 10000; + /* When we read wall clock dates (e.g. from UTMP), we need to map + them to the monotonic clock. Of course, such mapping defeats the + point of a monotonic clock in the first place, but we have litt= le + choice. */ + nowWallDelta =3D time(0) - now; } else #endif time(&now); @@ -486,11 +494,14 @@ checkUtmp(void) utp->hadSess =3D True; utp->state =3D UtActive; } + nck =3D ut->ut_time - nowWallDelta; + if (nck > now) + nck =3D 0; /* Clock jumped. Time out immediately. */ #ifdef HAVE_VTS /* tty with latest activity wins */ - if (utp->time < ut->ut_time) + if (utp->time < nck) #endif - utp->time =3D ut->ut_time; + utp->time =3D nck; } #ifdef BSD_UTMP close(fd); diff --git a/kdm/backend/dm.h b/kdm/backend/dm.h index 64e106b..b2f8c61 100644 --- a/kdm/backend/dm.h +++ b/kdm/backend/dm.h @@ -406,12 +406,16 @@ int activateVT(int vt); #ifndef _POSIX_MONOTONIC_CLOCK # define _POSIX_MONOTONIC_CLOCK -1 #endif -#if (_POSIX_MONOTONIC_CLOCK > 0) -# define nowMonotonic 1 -#elif (_POSIX_MONOTONIC_CLOCK < 0) +#if (_POSIX_MONOTONIC_CLOCK < 0) # define nowMonotonic 0 +# define nowWallDelta 0 #else +# if (_POSIX_MONOTONIC_CLOCK > 0) +# define nowMonotonic 1 +# else extern int nowMonotonic; +# endif +extern time_t nowWallDelta; #endif void updateNow(void); =20