[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kde-workspace/KDE/4.11] kdm/backend: fix resumption from console mode when monotonic clock is in us
From: Oswald Buddenhagen <ossi () kde ! org>
Date: 2014-03-28 17:06:55
Message-ID: E1WTaF5-0000HO-BA () scm ! kde ! org
[Download RAW message or body]
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/3b3f247f28b25e61a9d1820ea25f3c4a2b699a1d
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 = { 0, 0, 0, TO_INF, TO_INF, 0, 0, 0 };
time_t now;
-#ifndef nowMonotonic
+#if (_POSIX_MONOTONIC_CLOCK >= 0)
+time_t nowWallDelta;
+# ifndef nowMonotonic
int nowMonotonic;
+# endif
#endif
#if KDM_LIBEXEC_STRIP != -1
@@ -339,6 +342,11 @@ updateNow(void)
clock_gettime(CLOCK_MONOTONIC, &ts);
/* Linux' monotonic clock starts at zero, but this is assumed to mean "long ago". */
now = 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 little
+ choice. */
+ nowWallDelta = time(0) - now;
} else
#endif
time(&now);
@@ -486,11 +494,14 @@ checkUtmp(void)
utp->hadSess = True;
utp->state = UtActive;
}
+ nck = ut->ut_time - nowWallDelta;
+ if (nck > now)
+ nck = 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 = ut->ut_time;
+ utp->time = 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);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic