r22395: allow profiling level to be set on startup
authorHerb Lewis <herb@samba.org>
Fri, 20 Apr 2007 01:52:44 +0000 (01:52 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:19:32 +0000 (12:19 -0500)
source/profile/profile.c
source/smbd/server.c

index 686d130b567f20554842292dd1ee9765ad649bef..b7a2ea23beb60c3f90fc66695f40064ef101f3af 100644 (file)
@@ -42,14 +42,10 @@ BOOL do_profile_flag = False;
 BOOL do_profile_times = False;
 
 /****************************************************************************
-receive a set profile level message
+Set a profiling level.
 ****************************************************************************/
-void profile_message(int msg_type, struct process_id src,
-                    void *buf, size_t len, void *private_data)
+void set_profile_level(int level, struct process_id src)
 {
-        int level;
-
-       memcpy(&level, buf, sizeof(int));
 #ifdef WITH_PROFILE
        switch (level) {
        case 0:         /* turn off profiling */
@@ -94,6 +90,17 @@ void profile_message(int msg_type, struct process_id src,
 #endif /* WITH_PROFILE */
 }
 
+/****************************************************************************
+receive a set profile level message
+****************************************************************************/
+void profile_message(int msg_type, struct process_id src, void *buf, size_t len, void *private_data)
+{
+        int level;
+
+       memcpy(&level, buf, sizeof(int));
+       set_profile_level(level, src);
+}
+
 /****************************************************************************
 receive a request profile level message
 ****************************************************************************/
index 348d3354d7056b66cb72e12a101e70c50657a4d8..f1efcd41e91209a374d9a2c3ecd4c89db0796100 100644 (file)
@@ -863,6 +863,7 @@ extern void build_options(BOOL screen);
        static BOOL no_process_group = False;
        static BOOL log_stdout = False;
        static char *ports = NULL;
+       static char *profile_level = NULL;
        int opt;
        poptContext pc;
 
@@ -875,6 +876,7 @@ extern void build_options(BOOL screen);
        {"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
        {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" },
        {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"},
+       {"profiling-level", 'P', POPT_ARG_STRING, &profile_level, 0, "Set profiling level","PROFILE_LEVEL"},
        POPT_COMMON_SAMBA
        POPT_COMMON_DYNCONFIG
        POPT_TABLEEND
@@ -997,6 +999,14 @@ extern void build_options(BOOL screen);
                DEBUG(0,("ERROR: failed to setup profiling\n"));
                return -1;
        }
+       if (profile_level != NULL) {
+               int pl = atoi(profile_level);
+               struct process_id src;
+
+               DEBUG(1, ("setting profiling level: %s\n",profile_level));
+               src.pid = getpid();
+               set_profile_level(pl, src);
+       }
 #endif
 
        DEBUG(3,( "loaded services\n"));