开发者

why FreeBSD getting TCP socket option needs to lock write-lock?

开发者 https://www.devze.com 2023-02-08 00:30 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消