This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3] Fix double-checked locking in _res_hconf_reorder_addrs [BZ #19074]


On 10/14/2015 02:11 PM, Torvald Riegel wrote:
>> > -      /* Recheck, somebody else might have done the work by now.  */
>> > -      if (num_ifs <= 0)
>> > +      /* Recheck, somebody else might have done the work by now.  A
>> > +	 relaxed load is sufficient because we have the lock, and
>> > +	 num_ifs is only updated under the lock.  */

> That's not really the reason why the relaxed MO load is okay.  You cite
> just concurrent updates to num_ifs, but the relation to these is not
> affected by the MO here.  The MOs are about ordering, so you'd need a
> reason related to ordering here, informally.
> I would instead just refer to point (3) below.

Right, we don't need a non-atomic load here, but you wanted one in case
of future changes.

I'll commit this:

      /* Recheck, somebody else might have done the work by now.  No
	 ordering is required for the load because we have the lock,
	 and num_ifs is only updated under the lock.  Also see (3) in
	 the analysis below.  */

I've incorporated your other changes.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]