why FreeBSD getting TCP socket option needs to lock write-lock?
In FreeBSD, for getting TCP socket options (in tcp_ctloutput() in tcp_usrreq.c), it needs to do lock with INP_WLOCK(inp) as setting socket options does. Since getting TCP socket option only read some data from tcp co开发者_JS百科ntrol block and does not change data, I am curious why we do not use read lock with INP_RLOCK(inp) for a better performance.
If you don't put a write lock on it, the options could possibly change while reading it, producing bogus results.
精彩评论