Blame SOURCES/autofs-5.1.2-factor-out-set-thread-mount-request-log-id.patch

306fa1
autofs-5.1.2 - factor out set_thread_mount_request_log_id()
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
Factor out setting the thread mount request log id.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG           |    1 +
306fa1
 daemon/automount.c  |   24 +++++++++++++++++++++++-
306fa1
 daemon/direct.c     |   17 +----------------
306fa1
 daemon/indirect.c   |   17 +----------------
306fa1
 include/automount.h |    3 ++-
306fa1
 5 files changed, 28 insertions(+), 34 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -238,6 +238,7 @@
306fa1
 - add the mount requestor's pid to pending_args.
306fa1
 - create thread-local ID for mount attempts.
306fa1
 - log functions to prefix messages with attempt_id if available.
306fa1
+- factor out set_thread_mount_request_log_id().
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/daemon/automount.c
306fa1
+++ autofs-5.0.7/daemon/automount.c
306fa1
@@ -100,7 +100,7 @@ static int umount_all(struct autofs_poin
306fa1
 extern struct master *master_list;
306fa1
 
306fa1
 /* simple string hash based on public domain sdbm library */
306fa1
-unsigned long sdbm_hash(const char *str, unsigned long seed)
306fa1
+static unsigned long sdbm_hash(const char *str, unsigned long seed)
306fa1
 {
306fa1
 	unsigned long hash = seed;
306fa1
 	char c;
306fa1
@@ -110,6 +110,28 @@ unsigned long sdbm_hash(const char *str,
306fa1
 	return hash;
306fa1
 }
306fa1
 
306fa1
+void set_thread_mount_request_log_id(struct pending_args *mt)
306fa1
+{
306fa1
+	char attempt_id_comp[20];
306fa1
+	unsigned long *attempt_id;
306fa1
+	int status;
306fa1
+
306fa1
+	attempt_id = pthread_getspecific(key_thread_attempt_id);
306fa1
+	if (attempt_id == NULL) {
306fa1
+		attempt_id = (unsigned long *) calloc(1, sizeof(unsigned long));
306fa1
+		if (attempt_id  == NULL)
306fa1
+			fatal(ENOMEM);
306fa1
+		snprintf(attempt_id_comp, 20, "%ld", mt->wait_queue_token);
306fa1
+		*attempt_id = sdbm_hash(attempt_id_comp, 0);
306fa1
+		snprintf(attempt_id_comp, 20, "%u", mt->pid);
306fa1
+		*attempt_id = sdbm_hash(attempt_id_comp, *attempt_id);
306fa1
+		*attempt_id = sdbm_hash(mt->name, *attempt_id);
306fa1
+		status = pthread_setspecific(key_thread_attempt_id, attempt_id);
306fa1
+		if (status != 0)
306fa1
+			fatal(status);
306fa1
+	}
306fa1
+}
306fa1
+
306fa1
 static int do_mkdir(const char *parent, const char *path, mode_t mode)
306fa1
 {
306fa1
 	int status;
306fa1
--- autofs-5.0.7.orig/daemon/direct.c
306fa1
+++ autofs-5.0.7/daemon/direct.c
306fa1
@@ -1210,8 +1210,6 @@ static void *do_mount_direct(void *arg)
306fa1
 	struct autofs_point *ap;
306fa1
 	struct stat st;
306fa1
 	int status, state;
306fa1
-	char attempt_id_comp[20];
306fa1
-	unsigned long *attempt_id;
306fa1
 
306fa1
 	args = (struct pending_args *) arg;
306fa1
 
306fa1
@@ -1221,20 +1219,7 @@ static void *do_mount_direct(void *arg)
306fa1
 
306fa1
 	ap = mt.ap;
306fa1
 
306fa1
-	attempt_id = pthread_getspecific(key_thread_attempt_id);
306fa1
-	if (attempt_id == NULL) {
306fa1
-		attempt_id = (unsigned long *) calloc(1, sizeof(unsigned long));
306fa1
-		if (attempt_id == NULL)
306fa1
-			fatal(ENOMEM);
306fa1
-		snprintf(attempt_id_comp, 20, "%ld", mt.wait_queue_token);
306fa1
-		*attempt_id = sdbm_hash(attempt_id_comp, 0);
306fa1
-		snprintf(attempt_id_comp, 20, "%u", mt.pid);
306fa1
-		*attempt_id = sdbm_hash(attempt_id_comp, *attempt_id);
306fa1
-		*attempt_id = sdbm_hash(mt.name, *attempt_id);
306fa1
-		status = pthread_setspecific(key_thread_attempt_id, attempt_id);
306fa1
-		if (status != 0)
306fa1
-			fatal(status);
306fa1
-	}
306fa1
+	set_thread_mount_request_log_id(&mt;;
306fa1
 
306fa1
 	args->signaled = 1;
306fa1
 	status = pthread_cond_signal(&args->cond);
306fa1
--- autofs-5.0.7.orig/daemon/indirect.c
306fa1
+++ autofs-5.0.7/daemon/indirect.c
306fa1
@@ -726,8 +726,6 @@ static void *do_mount_indirect(void *arg
306fa1
 	char buf[PATH_MAX + 1];
306fa1
 	struct stat st;
306fa1
 	int len, status, state;
306fa1
-	char attempt_id_comp[20];
306fa1
-	unsigned long *attempt_id;
306fa1
 
306fa1
 	args = (struct pending_args *) arg;
306fa1
 
306fa1
@@ -737,20 +735,7 @@ static void *do_mount_indirect(void *arg
306fa1
 
306fa1
 	ap = mt.ap;
306fa1
 
306fa1
-	attempt_id = pthread_getspecific(key_thread_attempt_id);
306fa1
-	if (attempt_id == NULL) {
306fa1
-		attempt_id = (unsigned long *) calloc(1, sizeof(unsigned long));
306fa1
-		if (attempt_id  == NULL)
306fa1
-			fatal(ENOMEM);
306fa1
-		snprintf(attempt_id_comp, 20, "%ld", mt.wait_queue_token);
306fa1
-		*attempt_id = sdbm_hash(attempt_id_comp, 0);
306fa1
-		snprintf(attempt_id_comp, 20, "%u", mt.pid);
306fa1
-		*attempt_id = sdbm_hash(attempt_id_comp, *attempt_id);
306fa1
-		*attempt_id = sdbm_hash(mt.name, *attempt_id);
306fa1
-		status = pthread_setspecific(key_thread_attempt_id, attempt_id);
306fa1
-		if (status != 0)
306fa1
-			fatal(status);
306fa1
-	}
306fa1
+	set_thread_mount_request_log_id(&mt;;
306fa1
 
306fa1
 	args->signaled = 1;
306fa1
 	status = pthread_cond_signal(&args->cond);
306fa1
--- autofs-5.0.7.orig/include/automount.h
306fa1
+++ autofs-5.0.7/include/automount.h
306fa1
@@ -243,7 +243,8 @@ const char **copy_argv(int argc, const c
306fa1
 int compare_argv(int argc1, const char **argv1, int argc2, const char **argv2);
306fa1
 int free_argv(int argc, const char **argv);
306fa1
 
306fa1
-unsigned long sdbm_hash(const char *str, unsigned long seed);
306fa1
+struct pending_args;
306fa1
+void set_thread_mount_request_log_id(struct pending_args *mt);
306fa1
 
306fa1
 void dump_core(void);
306fa1
 int aquire_lock(void);