Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Mar 2011 17:01:34 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-net@freebsd.org
Cc:        Jim <uukkhh@gmail.com>, Robert Watson <rwatson@freebsd.org>
Subject:   Re: why use INP_WLOCK instead of INP_RLOCK
Message-ID:  <201103251701.34576.jhb@freebsd.org>
In-Reply-To: <AANLkTinrVJ4jehNm7xh=ix7k3r0Q0YY38nc59AkgiP_P@mail.gmail.com>
References:  <AANLkTinrVJ4jehNm7xh=ix7k3r0Q0YY38nc59AkgiP_P@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, February 01, 2011 12:54:33 am Jim wrote:
> Hi All,
> 
> I am not sure if anybody has asked it before. I could not find answer by
> doing rough search on Internet, if it is duplicate question, sorry in
> advance.
> 
> My question is that, for getting socket options in tcp_ctloutput() in
> tcp_usrreq.c, why do we need to do lock with INP_WLOCK(inp) as setting
> socket options does. Why do we just use INP_RLOCK(inp), as it looks not
> changing anything in tcp control block?
> 
> Thank you for your kindly answer.

I think mostly it is just because no one has bothered to change it.  
Realistically it probably won't make any noticable difference unless your 
workload consists of doing lots of calls to getsockopt() but not sending any 
actual traffic on the associated sockets. :)  (Almost all of the other 
operations on a TCP connection require a write lock on the pcb.)

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103251701.34576.jhb>