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