Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/uipc_socket.c
Context not available. | |||||
sodealloc(so); | sodealloc(so); | ||||
} | } | ||||
/* | |||||
* Let socket in same load balance group (same port and address) | |||||
* inherit pending sockets of the closing socket. | |||||
* | |||||
* "so_inh" will inherit sockets from "so" | |||||
*/ | |||||
rwatson: Comment should be a full sentence. | |||||
void | |||||
soinherit(struct socket *so, struct socket *so_inh) | |||||
{ | |||||
TAILQ_HEAD(, socket) comp, incomp; | |||||
struct socket *sp, *head, *head_inh; | |||||
int qlen, incqlen; | |||||
KASSERT(so->so_options & SO_ACCEPTCONN, | |||||
("so does not accept connection")); | |||||
KASSERT(so_inh->so_options & SO_ACCEPTCONN, | |||||
("so_inh does not accept connection")); | |||||
restart: | |||||
SOCK_LOCK(so); | |||||
if ((head = so->so_listen) != NULL && | |||||
__predict_false(SOLISTEN_TRYLOCK(head) == 0)) { | |||||
SOCK_UNLOCK(so); | |||||
goto restart; | |||||
} | |||||
restart_inh: | |||||
SOCK_LOCK(so_inh); | |||||
Done Inline ActionsThis is a second socket-lock acquisition in a row. How can we convince ourselves that this is safe? rwatson: This is a second socket-lock acquisition in a row. How can we convince ourselves that this is… | |||||
Not Done Inline ActionsBy simply re-order the code a bit we can unlock the first one before we lock the other. johalun0_gmail.com: By simply re-order the code a bit we can unlock the first one before we lock the other. | |||||
if ((head_inh = so_inh->so_listen) != NULL && | |||||
__predict_false(SOLISTEN_TRYLOCK(head_inh) == 0)) { | |||||
SOCK_UNLOCK(so_inh); | |||||
goto restart_inh; | |||||
} | |||||
TAILQ_INIT(&comp); | |||||
TAILQ_INIT(&incomp); | |||||
/* | |||||
* Save completed queue and incompleted queue | |||||
*/ | |||||
TAILQ_CONCAT(&comp, &so->sol_comp, so_list); | |||||
qlen = so->sol_qlen; | |||||
so->sol_qlen = 0; | |||||
TAILQ_CONCAT(&incomp, &so->sol_incomp, so_list); | |||||
incqlen = so->sol_incqlen; | |||||
so->sol_incqlen = 0; | |||||
/* | |||||
* Append the saved completed queue and incompleted | |||||
* queue to the socket inherits them. | |||||
* | |||||
* XXX | |||||
* This may temporarily break the inheriting socket's | |||||
* so_qlimit. | |||||
*/ | |||||
TAILQ_FOREACH(sp, &comp, so_list) { | |||||
refcount_acquire(&so_inh->so_count); | |||||
sp->so_listen = so_inh; | |||||
crfree(sp->so_cred); | |||||
sp->so_cred = crhold(so_inh->so_cred); | |||||
} | |||||
TAILQ_FOREACH(sp, &incomp, so_list) { | |||||
refcount_acquire(&so_inh->so_count); | |||||
sp->so_listen = so_inh; | |||||
crfree(sp->so_cred); | |||||
sp->so_cred = crhold(so_inh->so_cred); | |||||
} | |||||
TAILQ_CONCAT(&so_inh->sol_comp, &comp, so_list); | |||||
so_inh->sol_qlen += qlen; | |||||
TAILQ_CONCAT(&so_inh->sol_incomp, &incomp, so_list); | |||||
so_inh->sol_incqlen += incqlen; | |||||
SOCK_UNLOCK(so); | |||||
if(head != NULL) | |||||
Done Inline ActionsMissing space after "if". rwatson: Missing space after "if". | |||||
SOLISTEN_UNLOCK(head); | |||||
SOCK_UNLOCK(so_inh); | |||||
if(head_inh != NULL) { | |||||
Done Inline ActionsMissing space after "if". rwatson: Missing space after "if". | |||||
if(qlen > 0) { | |||||
Done Inline ActionsMissing space after "if". rwatson: Missing space after "if". | |||||
/* | |||||
* "New" connections have arrived | |||||
*/ | |||||
solisten_wakeup(head_inh); | |||||
} else { | |||||
SOLISTEN_UNLOCK(head_inh); | |||||
} | |||||
} | |||||
} | |||||
/* | /* | ||||
* Close a socket on last file table reference removal. Initiate disconnect | * Close a socket on last file table reference removal. Initiate disconnect | ||||
* if connected. Free socket when disconnect complete. | * if connected. Free socket when disconnect complete. | ||||
Context not available. | |||||
case SO_BROADCAST: | case SO_BROADCAST: | ||||
case SO_REUSEADDR: | case SO_REUSEADDR: | ||||
case SO_REUSEPORT: | case SO_REUSEPORT: | ||||
case SO_REUSEPORT_LB: | |||||
case SO_OOBINLINE: | case SO_OOBINLINE: | ||||
case SO_TIMESTAMP: | case SO_TIMESTAMP: | ||||
case SO_BINTIME: | case SO_BINTIME: | ||||
Context not available. | |||||
case SO_KEEPALIVE: | case SO_KEEPALIVE: | ||||
case SO_REUSEADDR: | case SO_REUSEADDR: | ||||
case SO_REUSEPORT: | case SO_REUSEPORT: | ||||
case SO_REUSEPORT_LB: | |||||
case SO_BROADCAST: | case SO_BROADCAST: | ||||
case SO_OOBINLINE: | case SO_OOBINLINE: | ||||
case SO_ACCEPTCONN: | case SO_ACCEPTCONN: | ||||
Context not available. |
Comment should be a full sentence.