diff options
Diffstat (limited to 'glusterfsd/src/glusterfsd.c')
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index c9c7ad065a5..2b6ee54523b 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -492,7 +492,7 @@ gf_remember_xlator_option (struct list_head *options, char *arg) char *dot = NULL; char *equals = NULL; - ctx = glusterfs_ctx_get (); + ctx = glusterfsd_ctx; cmd_args = &ctx->cmd_args; option = GF_CALLOC (1, sizeof (xlator_cmdline_option_t), @@ -560,7 +560,6 @@ out: static error_t parse_opts (int key, char *arg, struct argp_state *state) { - glusterfs_ctx_t *ctx = NULL; cmd_args_t *cmd_args = NULL; uint32_t n = 0; double d = 0.0; @@ -833,8 +832,7 @@ parse_opts (int key, char *arg, struct argp_state *state) case ARGP_MEM_ACCOUNTING_KEY: /* TODO: it should have got handled much earlier */ - ctx = glusterfs_ctx_get (); - ctx->mem_accounting = 1; + gf_mem_acct_enable_set (); break; case ARGP_FOPEN_KEEP_CACHE_KEY: @@ -859,7 +857,7 @@ cleanup_and_exit (int signum) glusterfs_ctx_t *ctx = NULL; xlator_t *trav = NULL; - ctx = glusterfs_ctx_get (); + ctx = glusterfsd_ctx; if (!ctx) return; @@ -918,7 +916,7 @@ reincarnate (int signum) glusterfs_ctx_t *ctx = NULL; cmd_args_t *cmd_args = NULL; - ctx = glusterfs_ctx_get (); + ctx = glusterfsd_ctx; cmd_args = &ctx->cmd_args; if (cmd_args->volfile_server) { @@ -1190,12 +1188,12 @@ logging_init (glusterfs_ctx_t *ctx) } void -gf_check_and_set_mem_acct (int argc, char *argv[], glusterfs_ctx_t *ctx) +gf_check_and_set_mem_acct (int argc, char *argv[]) { int i = 0; for (i = 0; i < argc; i++) { if (strcmp (argv[i], "--mem-accounting") == 0) { - ctx->mem_accounting = 1; + gf_mem_acct_enable_set (); break; } } @@ -1463,10 +1461,10 @@ glusterfs_sigwaiter (void *arg) reincarnate (sig); break; case SIGUSR1: - gf_proc_dump_info (sig); + gf_proc_dump_info (sig, glusterfsd_ctx); break; case SIGUSR2: - gf_latency_toggle (sig); + gf_latency_toggle (sig, glusterfsd_ctx); break; default: @@ -1478,6 +1476,13 @@ glusterfs_sigwaiter (void *arg) } +void +glusterfsd_print_trace (int signum) +{ + gf_print_trace (signum, glusterfsd_ctx); +} + + int glusterfs_signals_setup (glusterfs_ctx_t *ctx) { @@ -1487,12 +1492,12 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx) sigemptyset (&set); /* common setting for all threads */ - signal (SIGSEGV, gf_print_trace); - signal (SIGABRT, gf_print_trace); - signal (SIGILL, gf_print_trace); - signal (SIGTRAP, gf_print_trace); - signal (SIGFPE, gf_print_trace); - signal (SIGBUS, gf_print_trace); + signal (SIGSEGV, glusterfsd_print_trace); + signal (SIGABRT, glusterfsd_print_trace); + signal (SIGILL, glusterfsd_print_trace); + signal (SIGTRAP, glusterfsd_print_trace); + signal (SIGFPE, glusterfsd_print_trace); + signal (SIGBUS, glusterfsd_print_trace); signal (SIGINT, cleanup_and_exit); signal (SIGPIPE, SIG_IGN); @@ -1504,7 +1509,7 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx) ret = pthread_sigmask (SIG_BLOCK, &set, NULL); if (ret) { - gf_log ("", GF_LOG_WARNING, + gf_log ("glusterfsd", GF_LOG_WARNING, "failed to execute pthread_signmask %s", strerror (errno)); return ret; @@ -1518,7 +1523,7 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx) fallback to signals getting handled by other threads. setup the signal handlers */ - gf_log ("", GF_LOG_WARNING, + gf_log ("glusterfsd", GF_LOG_WARNING, "failed to create pthread %s", strerror (errno)); return ret; @@ -1667,6 +1672,9 @@ out: } +/* This is the only legal global pointer */ +glusterfs_ctx_t *glusterfsd_ctx; + int main (int argc, char *argv[]) { @@ -1677,16 +1685,20 @@ main (int argc, char *argv[]) if (ret) return ret; - ctx = glusterfs_ctx_get (); +#ifndef DEBUG + /* Enable memory accounting on the fly based on argument */ + gf_check_and_set_mem_acct (argc, argv); +#endif + + ctx = glusterfs_ctx_new (); if (!ctx) { gf_log ("glusterfs", GF_LOG_CRITICAL, "ERROR: glusterfs context not initialized"); return ENOMEM; } -#ifndef DEBUG - /* Enable memory accounting on the fly based on argument */ - gf_check_and_set_mem_acct (argc, argv, ctx); -#endif + glusterfsd_ctx = ctx; + THIS->ctx = ctx; + ret = glusterfs_ctx_defaults_init (ctx); if (ret) goto out; |