[Pvfs2-cvs] commit by slang in pvfs2/src/apps/kernel/linux: pvfs2-client-core.c

CVS commit program cvs at parl.clemson.edu
Wed Oct 25 11:02:46 EDT 2006


Update of /projects/cvsroot/pvfs2/src/apps/kernel/linux
In directory parlweb1:/tmp/cvs-serv18725/src/apps/kernel/linux

Modified Files:
	pvfs2-client-core.c 
Log Message:
I want to be able to run client core standalone without recompiling.  This is a hidden option for now (doesn't get printed on --help).  Also, fprintfing to stderr after stderr had been reopened to /dev/null wasn't helping us get error messages to the log.


Index: pvfs2-client-core.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/kernel/linux/pvfs2-client-core.c,v
diff -p -u -r1.76 -r1.77
--- pvfs2-client-core.c	13 Sep 2006 21:31:57 -0000	1.76
+++ pvfs2-client-core.c	25 Oct 2006 15:02:46 -0000	1.77
@@ -63,14 +63,6 @@
 #define PVFS2_CLIENT_DEFAULT_TEST_TIMEOUT_MS 10
 
 /*
-  uncomment if you want to run this application stand-alone
-  (i.e. without the pvfs2-client wrapper).  this is only useful as a
-  developer and allows clean shutdown for valgrind debugging or
-  getting core dumps.  this is NOT a supported run mode
-*/
-/* #define STANDALONE_RUN_MODE */
-
-/*
   uncomment for timing of individual operation information to be
   emitted to the pvfs2-client logging output
 */
@@ -106,6 +98,7 @@ typedef struct
     char* gossip_mask;
     int logstamp_type;
     int logstamp_type_set;
+    int standalone;
 } options_t;
 
 /*
@@ -259,12 +252,10 @@ static void client_segfault_handler(int 
     abort();
 }
 
-#ifdef STANDALONE_RUN_MODE
 static void client_core_sig_handler(int signum)
 {
     s_client_is_processing = 0;
 }
-#endif
 
 static int hash_key(void *key, int table_size)
 {
@@ -3060,20 +3051,6 @@ int main(int argc, char **argv)
     PINT_client_sm *acache_timer_sm_p = NULL;
     PINT_client_sm *ncache_timer_sm_p = NULL;
 
-#ifndef STANDALONE_RUN_MODE
-    struct rlimit lim = {0,0};
-
-    /* set rlimit to prevent core files */
-    ret = setrlimit(RLIMIT_CORE, &lim);
-    if (ret < 0)
-    {
-	fprintf(stderr, "setrlimit system call failed (%d); "
-                "continuing", ret);
-    }
-#else
-    signal(SIGINT, client_core_sig_handler);
-#endif
-
     /* if pvfs2-client-core segfaults, at least log the occurence so
      * pvfs2-client won't repeatedly respawn pvfs2-client-core */
     signal(SIGSEGV, client_segfault_handler);
@@ -3081,6 +3058,25 @@ int main(int argc, char **argv)
     memset(&s_opts, 0, sizeof(options_t));
     parse_args(argc, argv, &s_opts);
 
+    if(!s_opts.standalone)
+    {
+        struct rlimit lim = {0,0};
+
+        /* set rlimit to prevent core files */
+        ret = setrlimit(RLIMIT_CORE, &lim);
+        if (ret < 0)
+        {
+            fprintf(stderr, "setrlimit system call failed (%d); "
+                    "continuing", ret);
+        }
+    }
+    else
+    {
+        signal(SIGINT,  client_core_sig_handler);
+        signal(SIGHUP,  client_core_sig_handler);
+        signal(SIGQUIT, client_core_sig_handler);
+    }
+
     /* convert gossip mask if provided on command line */
     if (s_opts.gossip_mask)
     {
@@ -3156,14 +3152,14 @@ int main(int argc, char **argv)
     acache_pc = PINT_perf_initialize(acache_keys);
     if(!acache_pc)
     {
-        fprintf(stderr, "Error: PINT_perf_initialize failure.\n");
+        gossip_err("Error: PINT_perf_initialize failure.\n");
         return(-PVFS_ENOMEM);
     }
     ret = PINT_perf_set_info(acache_pc, PINT_PERF_HISTORY_SIZE,
         s_opts.perf_history_size);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: PINT_perf_set_info (history_size).\n");
+        gossip_err("Error: PINT_perf_set_info (history_size).\n");
         return(ret);
     }
     PINT_acache_enable_perf_counter(acache_pc);
@@ -3172,19 +3168,18 @@ int main(int argc, char **argv)
     ncache_pc = PINT_perf_initialize(ncache_keys);
     if(!ncache_pc)
     {
-        fprintf(stderr, "Error: PINT_perf_initialize failure.\n");
+        gossip_err("Error: PINT_perf_initialize failure.\n");
         return(-PVFS_ENOMEM);
     }
     ret = PINT_perf_set_info(ncache_pc, PINT_PERF_HISTORY_SIZE,
         s_opts.perf_history_size);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: PINT_perf_set_info (history_size).\n");
+        gossip_err("Error: PINT_perf_set_info (history_size).\n");
         return(ret);
     }
     PINT_ncache_enable_perf_counter(ncache_pc);
 
-    /* start a timer to roll over performance counters (acache) */
     acache_timer_sm_p = (PINT_client_sm *)malloc(sizeof(PINT_client_sm));
     if(!acache_timer_sm_p)
     {
@@ -3350,6 +3345,7 @@ static void parse_args(int argc, char **
         {"ncache-soft-limit",1,0,0},
         {"logfile",1,0,0},
         {"logstamp",1,0,0},
+        {"standalone",0,0,0},
         {0,0,0,0}
     };
 
@@ -3397,7 +3393,9 @@ static void parse_args(int argc, char **
                     }
                     else
                     {
-                        fprintf(stderr, "Error: invalid logstamp value. See usage below\n\n");
+                        gossip_err(
+                            "Error: invalid logstamp value. "
+                            "See usage below\n\n");
                         print_help(argv[0]);
                         exit(EXIT_FAILURE);
                     }
@@ -3408,7 +3406,8 @@ static void parse_args(int argc, char **
                     ret = sscanf(optarg, "%u", &opts->acache_hard_limit);
                     if(ret != 1)
                     {
-                        fprintf(stderr, "Error: invalid acache-hard-limit value.\n");
+                        gossip_err(
+                            "Error: invalid acache-hard-limit value.\n");
                         exit(EXIT_FAILURE);
                     }
                     opts->acache_hard_limit_set = 1;
@@ -3418,7 +3417,8 @@ static void parse_args(int argc, char **
                     ret = sscanf(optarg, "%u", &opts->acache_soft_limit);
                     if(ret != 1)
                     {
-                        fprintf(stderr, "Error: invalid acache-soft-limit value.\n");
+                        gossip_err(
+                            "Error: invalid acache-soft-limit value.\n");
                         exit(EXIT_FAILURE);
                     }
                     opts->acache_soft_limit_set = 1;
@@ -3428,7 +3428,9 @@ static void parse_args(int argc, char **
                     ret = sscanf(optarg, "%u", &opts->acache_reclaim_percentage);
                     if(ret != 1)
                     {
-                        fprintf(stderr, "Error: invalid acache-reclaim-percentage value.\n");
+                        gossip_err(
+                            "Error: invalid "
+                            "acache-reclaim-percentage value.\n");
                         exit(EXIT_FAILURE);
                     }
                     opts->acache_reclaim_percentage_set = 1;
@@ -3438,7 +3440,8 @@ static void parse_args(int argc, char **
                     ret = sscanf(optarg, "%u", &opts->ncache_hard_limit);
                     if(ret != 1)
                     {
-                        fprintf(stderr, "Error: invalid ncache-hard-limit value.\n");
+                        gossip_err(
+                            "Error: invalid ncache-hard-limit value.\n");
                         exit(EXIT_FAILURE);
                     }
                     opts->ncache_hard_limit_set = 1;
@@ -3448,7 +3451,8 @@ static void parse_args(int argc, char **
                     ret = sscanf(optarg, "%u", &opts->ncache_soft_limit);
                     if(ret != 1)
                     {
-                        fprintf(stderr, "Error: invalid ncache-soft-limit value.\n");
+                        gossip_err(
+                            "Error: invalid ncache-soft-limit value.\n");
                         exit(EXIT_FAILURE);
                     }
                     opts->ncache_soft_limit_set = 1;
@@ -3458,7 +3462,8 @@ static void parse_args(int argc, char **
                     ret = sscanf(optarg, "%u", &opts->ncache_reclaim_percentage);
                     if(ret != 1)
                     {
-                        fprintf(stderr, "Error: invalid ncache-reclaim-percentage value.\n");
+                        gossip_err(
+                            "Error: invalid ncache-reclaim-percentage value.\n");
                         exit(EXIT_FAILURE);
                     }
                     opts->ncache_reclaim_percentage_set = 1;
@@ -3469,7 +3474,8 @@ static void parse_args(int argc, char **
                         &opts->perf_time_interval_secs);
                     if(ret != 1)
                     {
-                        fprintf(stderr, "Error: invalid perf-time-interval-secs value.\n");
+                        gossip_err(
+                            "Error: invalid perf-time-interval-secs value.\n");
                         exit(EXIT_FAILURE);
                     }
                 }
@@ -3479,7 +3485,8 @@ static void parse_args(int argc, char **
                         &opts->perf_history_size);
                     if(ret != 1)
                     {
-                        fprintf(stderr, "Error: invalid perf-history-size value.\n");
+                        gossip_err(
+                            "Error: invalid perf-history-size value.\n");
                         exit(EXIT_FAILURE);
                     }
                 }
@@ -3487,6 +3494,10 @@ static void parse_args(int argc, char **
                 {
                     opts->gossip_mask = optarg;
                 }
+                else if (strcmp("standalone", cur_option) == 0)
+                {
+                    opts->standalone = 1;
+                }
                 break;
             case 'h':
           do_help:
@@ -3501,7 +3512,7 @@ static void parse_args(int argc, char **
                 opts->acache_timeout = atoi(optarg);
                 if (opts->acache_timeout < 0)
                 {
-                    fprintf(stderr, "Invalid acache timeout value of %d ms,"
+                    gossip_err("Invalid acache timeout value of %d ms,"
                                "disabling the acache.\n",
                                opts->acache_timeout);
                     opts->acache_timeout = 0;
@@ -3512,14 +3523,14 @@ static void parse_args(int argc, char **
                 opts->ncache_timeout = atoi(optarg);
                 if (opts->ncache_timeout < 0)
                 {
-                    fprintf(stderr, "Invalid ncache timeout value of %d ms,"
+                    gossip_err("Invalid ncache timeout value of %d ms,"
                                "disabling the ncache.\n",
                                opts->ncache_timeout);
                     opts->ncache_timeout = 0;
                 }
                 break;
             default:
-                fprintf(stderr, "Unrecognized option.  "
+                gossip_err("Unrecognized option.  "
                         "Try --help for information.\n");
                 exit(1);
         }



More information about the Pvfs2-cvs mailing list