freeradius-client thread safety & memleaks patch

Alex Massover alex at jajah.com
Sun Jul 25 11:29:50 CEST 2010


Hello,

I want to sync changes I did to CVS. No new functionality only fixes for thread-safety and fixing memory leaks.
I use this code with static (shared among threads) rc_handle and experience no segfaults and no memory leaks :)

Some parts of this patch we posted before, but this one combines them all and is prepared against current CVS.


Changes:

freeradius-client.h:
	- adding rad_hostent (will be used by ip_util.c)
	- changing functions signatures due to changes in ip_utils.c

avpair.c:
	- using localtime_r() instead of non-reentrant localtime()
	- fixing minor memory leak posted by somebody else (not me) to this mail list, but not applied yet
	- inet_ntoa() is not reentrant, using inet_ntop() instead
	- gmtime_r() instead of gmtime()

buildreq.c:
	- rc_get_id() is now simple, fast and reentrant.

config.c:
	- getservbyname_r() instead of getservbyname()
	- using rad_hostent in rc_gethostby*
	- fixing minor memleak - serv->secret[j] is not freed

ip_util.c:
	- using rad_hostent instead of thread-local buffer. Thread local storage is tricky and might leak in thread per request scenario
	- implementation of rc_ip_hostname() is copied from freeradius server. (something is wrong with current one)
	- using getservbyname_r() instead of getservbyname()

sendserver.c:
	- using new rc_ip_hostname()
	- using rand_r() instead of rand()



--
Best Regards,
Alex Massover
VoIP R&D TL
Jajah Inc.


	


This mail was sent via Mail-SeCure System.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: thread_safety.patch
Type: text/x-patch
Size: 13568 bytes
Desc: thread_safety.patch
URL: <http://lists.freeradius.org/pipermail/freeradius-devel/attachments/20100725/97e6dd90/attachment.bin>


More information about the Freeradius-Devel mailing list