File autofs-5-1-1-define-pending-condition-init-helper-function.patch of Package autofs.6209

From: Yu Ning <ning.yu@ubuntu.com>
Subject: autofs-5.1.1 - define pending condition init helper function
Git-repo: git://git.kernel.org/pub/scm/linux/storage/autofs/autofs.git
Git-commit: 90517499f624476f3aa58322b0ddcca5e9b8699a
Patch-mainline: 5.1.2
References: bsc#1046493

The time returned by gettimeofday() is affected by discontinuous jumps
in the system time, so it causes an issue that autofs may not auto
unmount a mount point if system time is manually changed by the system
administrator.

To fix the issue we need to convert to using a monotonic clock source
instead of the clock source used by gettimeofday().

We also want to use a monotonic clock source for the condition wait
of both the direct and indirect mount thread creation as well the
expire thread creation of each. So create a common helper function
to initialize a condition variable to use a monotonic clock source.

Signed-off-by: Yu Ning <ning.yu@ubuntu.com>
Signed-off-by: Ian Kent <raven@themaw.net>
Acked-by: Jeff Mahoney <jeffm@suse.com>
---
 include/automount.h |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

--- a/include/automount.h
+++ b/include/automount.h
@@ -395,6 +395,27 @@ struct pending_args {
 };
 
 #ifdef INCLUDE_PENDING_FUNCTIONS
+static void pending_cond_init(void *arg)
+{
+	struct pending_args *mt = (struct pending_args *) arg;
+	pthread_condattr_t condattrs;
+	int status;
+
+	status = pthread_condattr_init(&condattrs);
+	if (status)
+		fatal(status);
+
+	status = pthread_condattr_setclock(&condattrs, CLOCK_MONOTONIC);
+	if (status)
+		fatal(status);
+
+	status = pthread_cond_init(&mt->cond, &condattrs);
+	if (status)
+		fatal(status);
+
+	pthread_condattr_destroy(&condattrs);
+}
+
 static void pending_cond_destroy(void *arg)
 {
 	struct pending_args *mt = (struct pending_args *) arg;
openSUSE Build Service is sponsored by