[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 17/25: trans/crash: Fix setting core file template at runtime.
From: |
Samuel Thibault |
Subject: |
[hurd] 17/25: trans/crash: Fix setting core file template at runtime. |
Date: |
Mon, 24 Oct 2016 00:16:45 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 74998f9ded99c41d34c0db20e6eb7088fe51d742
Author: Justus Winter <address@hidden>
Date: Wed Oct 5 10:45:08 2016 +0200
trans/crash: Fix setting core file template at runtime.
* trans/crash.c (corefile_template_lock): New variable.
(S_crash_dump_task): Serialize access to 'corefile_template'.
(parse_opt): Likewise. Also strdup the template.
(trivfs_append_args): Serialize access to 'corefile_template'.
---
trans/crash.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/trans/crash.c b/trans/crash.c
index 0171cd7..f8e1658 100644
--- a/trans/crash.c
+++ b/trans/crash.c
@@ -30,6 +30,7 @@
#include <argz.h>
#include <sys/mman.h>
#include <assert.h>
+#include <pthread.h>
#include <version.h>
@@ -71,6 +72,7 @@ enum crash_action
static enum crash_action crash_how, crash_orphans_how;
static char *corefile_template;
+pthread_mutex_t corefile_template_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -336,12 +338,15 @@ S_crash_dump_task (mach_port_t port,
if (!err)
{
file_t sink = core_file;
+ pthread_mutex_lock (&corefile_template_lock);
if (corefile_template)
{
char *file_name;
file_name = template_make_file_name (corefile_template,
task, signo);
+ pthread_mutex_unlock (&corefile_template_lock);
+
if (file_name == NULL)
error (0, errno, "template_make_file_name");
else
@@ -356,6 +361,8 @@ S_crash_dump_task (mach_port_t port,
free (file_name);
}
}
+ else
+ pthread_mutex_unlock (&corefile_template_lock);
err = dump_core (task, sink,
(off_t) -1, /* XXX should get core limit in RPC */
@@ -645,10 +652,21 @@ parse_opt (int opt, char *arg, struct argp_state *state)
return EINVAL;
}
}
+ pthread_mutex_lock (&corefile_template_lock);
+ free (corefile_template);
if (strlen (arg) == 0)
corefile_template = NULL;
else
- corefile_template = arg;
+ {
+ corefile_template = strdup (arg);
+ if (corefile_template == NULL)
+ {
+ pthread_mutex_unlock (&corefile_template_lock);
+ argp_failure (state, 1, errno, "strdup");
+ return errno;
+ }
+ }
+ pthread_mutex_unlock (&corefile_template_lock);
break;
case ARGP_KEY_SUCCESS:
@@ -692,6 +710,7 @@ trivfs_append_args (struct trivfs_control *fsys,
err = argz_add (argz, argz_len, opt);
}
+ pthread_mutex_lock (&corefile_template_lock);
if (!err && corefile_template)
{
char *template;
@@ -703,6 +722,7 @@ trivfs_append_args (struct trivfs_control *fsys,
free (template);
}
}
+ pthread_mutex_unlock (&corefile_template_lock);
return err;
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 20/25: console-client: Remove unused variable., (continued)
- [hurd] 20/25: console-client: Remove unused variable., Samuel Thibault, 2016/10/23
- [hurd] 19/25: ext2fs: Poison pointers into dereferenced cache pages., Samuel Thibault, 2016/10/23
- [hurd] 08/25: libfshelp: acquire references to control ports, Samuel Thibault, 2016/10/23
- [hurd] 15/25: Avoid fatal error handling in option parsers., Samuel Thibault, 2016/10/23
- [hurd] 25/25: boot: Ignore EINTR., Samuel Thibault, 2016/10/23
- [hurd] 24/25: Avoid warnings if increasing a threads priority fails., Samuel Thibault, 2016/10/23
- [hurd] 18/25: ext2fs: Rename parameter., Samuel Thibault, 2016/10/23
- [hurd] 09/25: Fix installing runsystem.hurd, Samuel Thibault, 2016/10/23
- [hurd] 12/25: fakeroot: set FAKED_MODE, Samuel Thibault, 2016/10/23
- [hurd] 14/25: ext2fs: Disable option to specify alternate superblock., Samuel Thibault, 2016/10/23
- [hurd] 17/25: trans/crash: Fix setting core file template at runtime.,
Samuel Thibault <=
- [hurd] 21/25: fshelp: Fix fetching the control port., Samuel Thibault, 2016/10/23
- [hurd] 06/25: startup: Fix looping over runsystem, Samuel Thibault, 2016/10/23
- [hurd] 16/25: trans/crash: Use empty core file templates to disable the feature., Samuel Thibault, 2016/10/23
- [hurd] 13/25: libdiskfs: Fix short-circuiting translators., Samuel Thibault, 2016/10/23
- [hurd] 11/25: random: Hash continuous areas in the csprng pool., Samuel Thibault, 2016/10/23
- [hurd] 23/25: procfs: Gracefully degrade meminfo., Samuel Thibault, 2016/10/23
- [hurd] 22/25: Fix some RPC request headers #ifdef guards, Samuel Thibault, 2016/10/23