Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_subr.c
Context not available. | |||||
{ | { | ||||
struct inpcb *inp = tp->t_inpcb; | struct inpcb *inp = tp->t_inpcb; | ||||
struct socket *so; | struct socket *so; | ||||
struct inpcb *inp_inh = NULL; | |||||
int listen = tp->t_state & TCPS_LISTEN; | |||||
rwatson: I'm cautious about naming a variable "listen" -- historically, this would have shadowed a… | |||||
INP_INFO_LOCK_ASSERT(&V_tcbinfo); | INP_INFO_LOCK_ASSERT(&V_tcbinfo); | ||||
INP_WLOCK_ASSERT(inp); | INP_WLOCK_ASSERT(inp); | ||||
if (listen) { | |||||
/* | |||||
* Pending socket/syncache inheritance | |||||
* | |||||
* If this is a listen(2) socket, find another listen(2) | |||||
* socket in the same load balance group, which could inherit | |||||
* the syncache and sockets pending on the completion | |||||
* and incompletion queues. | |||||
Done Inline ActionsThe line wrapping here is funky. Make it consistently 78 characters wide. rwatson: The line wrapping here is funky. Make it consistently 78 characters wide. | |||||
* | |||||
* NOTE: | |||||
* Currently the inheritance could only happen on the | |||||
* listen(2) sockets with SO_REUSEPORT_LB set. | |||||
*/ | |||||
inp_inh = in_pcblookup_lbgroup_last(inp); | |||||
} | |||||
#ifdef TCP_OFFLOAD | #ifdef TCP_OFFLOAD | ||||
if (tp->t_state == TCPS_LISTEN) | if (tp->t_state == TCPS_LISTEN) | ||||
tcp_offload_listen_stop(tp); | tcp_offload_listen_stop(tp); | ||||
Done Inline Actionstcp_subr.c diff looks now unrelated, that is, only whitespace change here pluknet: tcp_subr.c diff looks now unrelated, that is, only whitespace change here | |||||
Not Done Inline ActionsGood catch! Will fix that. johalun0_gmail.com: Good catch! Will fix that. | |||||
Context not available. | |||||
tcp_state_change(tp, TCPS_CLOSED); | tcp_state_change(tp, TCPS_CLOSED); | ||||
KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL")); | KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL")); | ||||
so = inp->inp_socket; | so = inp->inp_socket; | ||||
Done Inline ActionsThis vertical whitespace is not required. rwatson: This vertical whitespace is not required. | |||||
soisdisconnected(so); | soisdisconnected(so); | ||||
if (listen && inp_inh != NULL) { | |||||
Not Done Inline ActionsHow about this locking? Is it needed for access to the socket and if so, is it safe to lock another inpcb here? johalun0_gmail.com: How about this locking? Is it needed for access to the socket and if so, is it safe to lock… | |||||
Not Done Inline ActionsThe INP lock is needed to check inp_socket and ensure it doesn't change while you are messing with the socket. (Actually, it could probably be a read lock.) Its safe to lock the inpcb first, and then lock that inpcb's socket while you hold the INP lock. If you want to lock two inpcbs, you will need to define a deadlock-free ordering. (See, for example, the way sched_ule.c does this in sched_switch_migrate().) jtl: The INP lock is needed to check inp_socket and ensure it doesn't change while you are messing… | |||||
INP_WLOCK(inp_inh); | |||||
if (inp_inh->inp_socket != NULL) { | |||||
soinherit(so, inp_inh->inp_socket); | |||||
} | |||||
INP_WUNLOCK(inp_inh); | |||||
} | |||||
if (inp->inp_flags & INP_SOCKREF) { | if (inp->inp_flags & INP_SOCKREF) { | ||||
KASSERT(so->so_state & SS_PROTOREF, | KASSERT(so->so_state & SS_PROTOREF, | ||||
("tcp_close: !SS_PROTOREF")); | ("tcp_close: !SS_PROTOREF")); | ||||
Context not available. |
I'm cautious about naming a variable "listen" -- historically, this would have shadowed a global symbol (listen()). I wonder if another name might be a better idea.