bionic/libc/netbsd
David 'Digit' Turner 4661fda2e5 libc: Fix leak in the DNS thread-specific state.
This patch fixes a leak that occurs when creating a new
thread-specific DNS resolver state object.

Essentially, each thread that calls gethostbyname() or getaddrinfo()
at least once will leak a small memory block. Another leak happens
anytime these functions are called after a change of the network
settings.

The leak is insignificant and hard to notice on typical programs.
However, netd tends to create one new thread for each DNS request
it processes, and quickly grows in size after a > 20 hours.

The same problem is seen in other system processes that tend to
create one thread per request too.

The leak occured becasue res_ninit() was called twice when creating
a new thread-specific DNS resolver state in _res_get_thread().

This function could not properly reset an existing thread and was
leaking a memory block.

The patch does two things:

- First, it fixes res_ninit() to prevent any leakage when resetting
  the state of a given res_state instance.

- Second, it modifies the _res_get_thread() implementation to
  make it more explicit, and avoid calling res_ninit() twice
  in a row on first-time creation.

Fix for Bug 4089945, and Bug 4090857

Change-Id: Ie4831a8dbe82be8f07fce5ddd1d36bf95994f836
2011-03-18 18:08:08 +01:00
..
inet auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
isc Remove compiler warnings when building Bionic. 2010-06-22 17:51:41 -07:00
nameser Remove compiler warnings when building Bionic. 2010-06-22 17:51:41 -07:00
net Convert cname lenght before use 2011-03-01 12:52:10 -08:00
resolv libc: Fix leak in the DNS thread-specific state. 2011-03-18 18:08:08 +01:00
gethnamaddr.c gethnamaddr: make helper functions static 2010-09-27 23:40:55 +08:00