[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r14311 - in /trunk/libc: ChangeLog.eglibc resolv/res_libc.c



Author: maxim
Date: Thu Jun 23 04:02:51 2011
New Revision: 14311

Log:
2011-06-23  Paul Pluzhnikov  <ppluzhnikov@xxxxxxxxxx>

	* resolv/res_libc.c (__res_initstamp): Declare unconditionally.
	(__res_maybe_init): Avoid double-checked locking.

Modified:
    trunk/libc/ChangeLog.eglibc
    trunk/libc/resolv/res_libc.c

Modified: trunk/libc/ChangeLog.eglibc
==============================================================================
--- trunk/libc/ChangeLog.eglibc (original)
+++ trunk/libc/ChangeLog.eglibc Thu Jun 23 04:02:51 2011
@@ -1,3 +1,8 @@
+2011-06-23  Paul Pluzhnikov  <ppluzhnikov@xxxxxxxxxx>
+
+	* resolv/res_libc.c (__res_initstamp): Declare unconditionally.
+	(__res_maybe_init): Avoid double-checked locking.
+
 2011-06-21  Joseph Myers  <joseph@xxxxxxxxxxxxxxxx>
 
 	* elf/pldd.c (argp_program_bug_address): Use REPORT_BUGS_TO.

Modified: trunk/libc/resolv/res_libc.c
==============================================================================
--- trunk/libc/resolv/res_libc.c (original)
+++ trunk/libc/resolv/res_libc.c Thu Jun 23 04:02:51 2011
@@ -28,6 +28,7 @@
    out) since res_init() should go into libc.so but the rest of that
    file should not.  */
 
+__libc_lock_define_initialized (static, lock);
 extern unsigned long long int __res_initstamp attribute_hidden;
 /* We have atomic increment operations on 64-bit platforms.  */
 #if __WORDSIZE == 64
@@ -35,7 +36,6 @@
 # define atomicincunlock(lock) (void) 0
 # define atomicinc(var) catomic_increment (&(var))
 #else
-__libc_lock_define_initialized (static, lock);
 # define atomicinclock(lock) __libc_lock_lock (lock)
 # define atomicincunlock(lock) __libc_lock_unlock (lock)
 # define atomicinc(var) ++var
@@ -100,12 +100,12 @@
 
 	if (resp->options & RES_INIT) {
 		ret = stat (_PATH_RESCONF, &statbuf);
+		__libc_lock_lock (lock);
 		if ((ret == 0) && (last_mtime != statbuf.st_mtime)) {
 			last_mtime = statbuf.st_mtime;
-			atomicinclock (lock);
 			atomicinc (__res_initstamp);
-			atomicincunlock (lock);
 		}
+		__libc_lock_unlock (lock);
 		if (__res_initstamp != resp->_u._ext.initstamp) {
 			if (resp->nscount > 0)
 				__res_iclose (resp, true);