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 v2] Make bindresvport() function to multithread-safe


On 9/19/2012 2:25 PM, Mike Frysinger wrote:
> On Wednesday 19 September 2012 02:56:08 Carlos O'Donell wrote:
>> On Tue, Sep 18, 2012 at 9:45 PM, Peng Haitao <penght@cn.fujitsu.com> wrote:
>>> bindresvport() uses two static variables port and startport which are not
>>> protected. It is not safe when in multithread circumstance.
>>>
>>> bindresvport() select a port number from the range 512 to 1023, when in
>>> multithread circumstance, the port may be 1024. So the static variables
>>> will be protected.
>>
>> This patch is unacceptable for two reasons:
>>
>> (a) We define bindresvport() as non-thread-safe. Therefore the change
>> is not required.
>>
>> and
>>
>> (b) Adding locking to bindresvport() will only slow down the fast path
>> in the function.
>>
>> You have provided no rationale for the change.
>>
>> Until you provide some rationale, or prove that performance doesn't
>> matter in the case of this function, the change is unacceptable.
>>
>> Does that make sense?
> 
> rather than adding locks, what if the static's had __thread added, and getpid 
> was changed to gettid.
> -mike
> 

That's a much more interesting solution.

Cheers,
Carlos.
-- 
Carlos O'Donell
Mentor Graphics / CodeSourcery
carlos_odonell@mentor.com
carlos@codesourcery.com
+1 (613) 963 1026


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