improved thread safety?

David Collier-Brown davecb at sun.com
Sat Jan 19 16:43:33 GMT 2008


Jelmer Vernooij wrote:
> Am Freitag, den 18.01.2008, 16:40 -0800 schrieb Robert Huber:
> 
>>Has thread safety improved much in version 4.0.0.1a over 4.0alpha?
> 
> Again, I'm a little bit confused by these version numbers. We never
> released a version 4.0.0.1a.
> 
> Except for the loadparm contexts, most code in Samba 4 does not use any
> global variables and so it should be possible to call it from different
> threads, as long as you don't share contexts between threads. Is that
> the sort of thing you're looking for? 


At the expense of writing you a long answer rather than a short one,
samba 4 uses the following functions which are mt-unsafe on Solaris
and other standard-compliant systems:
	gethostbyaddr
	gethostbyname
	getopt
	getpass
	getservbyport
	inet_addr
	inet_ntoa
	initgroups
	pclose
	popen
	random
	srandom
	system

I have a tool which finds these, and it found 290 lines of them.
such as:

"GIT/v4-0-test/source/lib/replace/getaddrinfo.c", line 110: gethostbyaddr
# gethostbyaddr
#      gethostbyaddr - network host database functions
#      MT-Level: MT-Unsafe

The non-comment lines are in error-message format, to make it
easy to use vim or emacs to review them all, and see if the
code around them uses locks or other techniques to make them
survive multi-threading.

Send me mail if you want data on mt-unsafe, non-posix, or
32-bit-only only code: the tool is really for porting, but
can inspect for all sorts of other things. See also
http://datacenterworks.com/stories/port.html  

--dave
-- 
David Collier-Brown            | Always do right. This will gratify
Sun Microsystems, Toronto      | some people and astonish the rest
davecb at sun.com                 |                      -- Mark Twain
(800) 555-9786 x56583 cell: (647) 833-9377 home off: (416) 223-5943 


More information about the samba-technical mailing list