Author: herb Date: 2007-04-20 01:52:44 +0000 (Fri, 20 Apr 2007) New Revision: 22395
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22395 Log: allow profiling level to be set on startup Modified: branches/SAMBA_3_0/source/profile/profile.c branches/SAMBA_3_0/source/smbd/server.c branches/SAMBA_3_0_25/source/profile/profile.c branches/SAMBA_3_0_25/source/smbd/server.c Changeset: Modified: branches/SAMBA_3_0/source/profile/profile.c =================================================================== --- branches/SAMBA_3_0/source/profile/profile.c 2007-04-19 23:47:55 UTC (rev 22394) +++ branches/SAMBA_3_0/source/profile/profile.c 2007-04-20 01:52:44 UTC (rev 22395) @@ -42,14 +42,10 @@ 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 */ @@ -95,6 +91,17 @@ } /**************************************************************************** +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 ****************************************************************************/ void reqprofile_message(int msg_type, struct process_id src, Modified: branches/SAMBA_3_0/source/smbd/server.c =================================================================== --- branches/SAMBA_3_0/source/smbd/server.c 2007-04-19 23:47:55 UTC (rev 22394) +++ branches/SAMBA_3_0/source/smbd/server.c 2007-04-20 01:52:44 UTC (rev 22395) @@ -863,6 +863,7 @@ 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 @@ {"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 @@ 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")); Modified: branches/SAMBA_3_0_25/source/profile/profile.c =================================================================== --- branches/SAMBA_3_0_25/source/profile/profile.c 2007-04-19 23:47:55 UTC (rev 22394) +++ branches/SAMBA_3_0_25/source/profile/profile.c 2007-04-20 01:52:44 UTC (rev 22395) @@ -42,13 +42,10 @@ 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 +91,17 @@ } /**************************************************************************** +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 ****************************************************************************/ void reqprofile_message(int msg_type, struct process_id src, Modified: branches/SAMBA_3_0_25/source/smbd/server.c =================================================================== --- branches/SAMBA_3_0_25/source/smbd/server.c 2007-04-19 23:47:55 UTC (rev 22394) +++ branches/SAMBA_3_0_25/source/smbd/server.c 2007-04-20 01:52:44 UTC (rev 22395) @@ -833,6 +833,7 @@ static BOOL no_process_group = False; static BOOL log_stdout = False; static char *ports = NULL; + static char *profile_level = NULL; int opt; poptContext pc; @@ -845,6 +846,7 @@ {"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 @@ -967,6 +969,14 @@ 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"));