nmbd crashes if built with profiling enabled

Richard Sharpe realrichardsharpe at gmail.com
Fri Feb 8 18:50:54 MST 2013


On Fri, Feb 8, 2013 at 4:45 PM, Jeremy Allison <jra at samba.org> wrote:
> On Fri, Feb 08, 2013 at 04:33:42PM -0800, Richard Sharpe wrote:
>> Hi folks,
>>
>> If you enable profiling during configure, nmbd will crash when
>> running. This is not usually a problem since no one really needs
>> profiling, but still.
>>
>> There is a missing #if WITH_PROFILE section similar to what there is
>> in source3/smbd/server.c
>
> Patch please !

This is from Ravi Mulam (also attached):

diff -Naur samba-3.4.5.orig/source3/nmbd/nmbd.c samba-3.4.5/source3/nmbd/nmbd.c
--- samba-3.4.5.orig/source3/nmbd/nmbd.c	2013-02-03 04:09:52.734130285 -0800
+++ samba-3.4.5/source3/nmbd/nmbd.c	2013-02-03 22:39:43.650084405 -0800
@@ -748,6 +748,7 @@
 	static bool Fork = true;
 	static bool no_process_group;
 	static bool log_stdout;
+    char *profile_level = NULL;
 	poptContext pc;
 	char *p_lmhosts = NULL;
 	int opt;
@@ -767,6 +768,7 @@
 	{"log-stdout", 'S', POPT_ARG_NONE, NULL, OPT_LOG_STDOUT, "Log to stdout" },
 	{"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 'H', "Load a netbios hosts file"},
 	{"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on
the specified port" },
+    {"profiling-level", 'P', POPT_ARG_STRING, &profile_level, 0, "Set
profiling level","PROFILE_LEVEL"},
 	POPT_COMMON_SAMBA
 	{ NULL }
 	};
@@ -858,6 +860,20 @@
 		DEBUG(0, ("error opening config file\n"));
 		exit(1);
 	}
+#ifdef WITH_PROFILE
+     if (!profile_setup(smbd_messaging_context(), False)) {
+         DEBUG(0,("ERROR: failed to setup profiling\n"));
+         return -1;
+     }
+     if (profile_level != NULL) {
+         int pl = atoi(profile_level);
+         struct server_id src;
+
+         DEBUG(1, ("setting profiling level: %s\n",profile_level));
+         src.pid = getpid();
+         set_profile_level(pl, src);
+     }
+ #endif

 	if (nmbd_messaging_context() == NULL) {
 		return 1;


-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: samba-nmbd-profile.patch
Type: application/octet-stream
Size: 1448 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20130208/73888b69/attachment.obj>


More information about the samba-technical mailing list