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