From: Mark Zealey Date: Wed, 4 Dec 2013 20:30:02 +0000 (+0000) Subject: mutex lock the g_localaddresses as under very rare conditions it can segfault at... X-Git-Tag: rec-3.6.0-rc1~239^2~5^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1d586b377bc68ba07ecad470e5809a071ff44889;p=thirdparty%2Fpdns.git mutex lock the g_localaddresses as under very rare conditions it can segfault at startup when initializing many receive threads with many addresses --- diff --git a/pdns/nameserver.cc b/pdns/nameserver.cc index 0e773fa300..990a7457c4 100644 --- a/pdns/nameserver.cc +++ b/pdns/nameserver.cc @@ -89,6 +89,7 @@ extern StatBag S; #endif vector g_localaddresses; // not static, our unit tests need to poke this +pthread_mutex_t localaddresses_lock=PTHREAD_MUTEX_INITIALIZER; void UDPNameserver::bindIPv4() { @@ -129,7 +130,10 @@ void UDPNameserver::bindIPv4() if(locala.sin4.sin_family != AF_INET) throw PDNSException("Attempting to bind IPv4 socket to IPv6 address"); + pthread_mutex_lock(&localaddresses_lock); g_localaddresses.push_back(locala); + pthread_mutex_unlock(&localaddresses_lock); + if(::bind(s, (sockaddr*)&locala, locala.getSocklen()) < 0) { L<