hrev49333 adds 1 changeset to branch 'master'
old head: 67c816c41c7d98852566fdeda1f4c36a31df474e
new head: 227af8c052dcdc287a785cb5a008a5a6d37b8c72
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=227af8c052dc+%5E67c816c41c7d
----------------------------------------------------------------------------
227af8c052dc: netresolv: ensure pthread_rwlock is initialized before use
Under some circumstances the pthread_rwlock protecting the name service
configuration was not initialized, and the calls to rdlock/wrlock would
silently fail.
[ Hamish Morrison <hamishm53@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev49333
Commit: 227af8c052dcdc287a785cb5a008a5a6d37b8c72
URL: http://cgit.haiku-os.org/haiku/commit/?id=227af8c052dc
Author: Hamish Morrison <hamishm53@xxxxxxxxx>
Date: Sun Jun 28 22:17:19 2015 UTC
----------------------------------------------------------------------------
1 file changed, 4 insertions(+), 3 deletions(-)
src/kits/network/netresolv/irs/nsdispatch.c | 7 ++++---
----------------------------------------------------------------------------
diff --git a/src/kits/network/netresolv/irs/nsdispatch.c
b/src/kits/network/netresolv/irs/nsdispatch.c
index 5169886..c84d4c9 100644
--- a/src/kits/network/netresolv/irs/nsdispatch.c
+++ b/src/kits/network/netresolv/irs/nsdispatch.c
@@ -158,7 +158,8 @@ static pthread_once_t _nslockinit =
PTHREAD_ONCE_INIT;
static void lockinit()
{
- pthread_rwlock_init(&_nslock, NULL);
+ int result = pthread_rwlock_init(&_nslock, NULL);
+ assert(result == 0);
}
/*
@@ -509,8 +510,6 @@ _nsconfigure(void)
return (0);
}
- pthread_once(&_nslockinit, lockinit);
-
/*
* Ok, we've decided we need to update the nsswitch configuration
* structures. Acquire a write-lock on _nslock while continuing
@@ -614,6 +613,8 @@ nsdispatch(void *retval, const ns_dtab disp_tab[], const
char *database,
if (database == NULL || method == NULL || defaults == NULL)
return (NS_UNAVAIL);
+ pthread_once(&_nslockinit, lockinit);
+
/*
* In both the threaded and non-threaded cases, avoid reloading
* the configuration if the current thread is already running