Date: Tue, 16 Aug 2016 06:01:57 -0700 From: Randall Stewart <rrs@netflix.com> To: Hans Petter Selasky <hps@selasky.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r304218 - head/sys/netinet Message-ID: <272AD783-2988-4EE7-89A5-EC6FA1313122@netflix.com> In-Reply-To: <92a3cfc1-56bc-813f-dd12-ac19c66fd716@selasky.org> References: <201608161240.u7GCeuWS082118@repo.freebsd.org> <92a3cfc1-56bc-813f-dd12-ac19c66fd716@selasky.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Sure
Let me add some comments for you. The idea her is that you pick-up a reference
to the PCB.. so it can’t be removed. Thus when you re-lock the INP you check the
dropped flag (just in case someone did get in).
Let me get that in comments.. (note thats also why when using this function you
have to use its companion function to drop the reference).
> On Aug 16, 2016, at 5:58 AM, Hans Petter Selasky <hps@selasky.org> wrote:
>
> On 08/16/16 14:40, Randall Stewart wrote:
>> +int
>> +tcp_inpinfo_lock_add(struct inpcb *inp)
>> +{
>> + in_pcbref(inp);
>> + INP_WUNLOCK(inp);
>> + INP_INFO_RLOCK(&V_tcbinfo);
>> + INP_WLOCK(inp);
>> + if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
>> + return(1);
>> + }
>> + return(0);
>> +
>> +}
>
> Hi,
>
> Could you add some comments describing how it is considered safe to drop the INP write-lock and then pick it up again?
>
> My first impression is that because you are dropping the inp lock, multiple threads can enter the code in question, leaving the window open to races?
>
> --HPS
--------
Randall Stewart
rrs@netflix.com
803-317-4952
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?272AD783-2988-4EE7-89A5-EC6FA1313122>
