Modify netatalk to ensure, and assert, that pcb's remain attached to
sockets as long as the sockets have not been aborted or detached. Do not try to free the socket in pru_detach(), since sofree() will do so, if needed, once pru_detach() returns. Annotate a bug in ddp_abort(), which fails to free the socket; this is probably OK as ddp_abort() should never be called, so should instead be deleted.
This commit is contained in:
parent
cbcf9b2ad9
commit
76be92c1fd
@ -302,12 +302,11 @@ at_pcbdetach(struct socket *so, struct ddpcb *ddp)
|
||||
*/
|
||||
DDP_LIST_XLOCK_ASSERT();
|
||||
DDP_LOCK_ASSERT(ddp);
|
||||
KASSERT(so->so_pcb != NULL, ("at_pcbdetach: so_pcb == NULL"));
|
||||
|
||||
/* XXXRW: Why bother to disconnect it now? */
|
||||
soisdisconnected(so);
|
||||
ACCEPT_LOCK();
|
||||
SOCK_LOCK(so);
|
||||
so->so_pcb = NULL;
|
||||
sotryfree(so);
|
||||
|
||||
/* remove ddp from ddp_ports list */
|
||||
if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT &&
|
||||
|
@ -56,8 +56,7 @@ ddp_attach(struct socket *so, int proto, struct thread *td)
|
||||
int error = 0;
|
||||
|
||||
ddp = sotoddpcb(so);
|
||||
if (ddp != NULL)
|
||||
return (EINVAL);
|
||||
KASSERT(ddp == NULL, ("ddp_attach: ddp != NULL"));
|
||||
|
||||
/*
|
||||
* Allocate socket buffer space first so that it's present
|
||||
@ -79,8 +78,7 @@ ddp_detach(struct socket *so)
|
||||
struct ddpcb *ddp;
|
||||
|
||||
ddp = sotoddpcb(so);
|
||||
if (ddp == NULL)
|
||||
return (EINVAL);
|
||||
KASSERT(ddp != NULL, ("ddp_detach: ddp == NULL"));
|
||||
|
||||
DDP_LIST_XLOCK();
|
||||
DDP_LOCK(ddp);
|
||||
@ -96,9 +94,7 @@ ddp_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
int error = 0;
|
||||
|
||||
ddp = sotoddpcb(so);
|
||||
if (ddp == NULL) {
|
||||
return (EINVAL);
|
||||
}
|
||||
KASSERT(ddp != NULL, ("ddp_bind: ddp == NULL"));
|
||||
DDP_LIST_XLOCK();
|
||||
DDP_LOCK(ddp);
|
||||
error = at_pcbsetaddr(ddp, nam, td);
|
||||
@ -114,10 +110,7 @@ ddp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
int error = 0;
|
||||
|
||||
ddp = sotoddpcb(so);
|
||||
if (ddp == NULL) {
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
KASSERT(ddp != NULL, ("ddp_connect: ddp == NULL"));
|
||||
DDP_LIST_XLOCK();
|
||||
DDP_LOCK(ddp);
|
||||
if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT) {
|
||||
@ -141,9 +134,7 @@ ddp_disconnect(struct socket *so)
|
||||
struct ddpcb *ddp;
|
||||
|
||||
ddp = sotoddpcb(so);
|
||||
if (ddp == NULL) {
|
||||
return (EINVAL);
|
||||
}
|
||||
KASSERT(ddp != NULL, ("ddp_disconnect: ddp == NULL"));
|
||||
DDP_LOCK(ddp);
|
||||
if (ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE) {
|
||||
DDP_UNLOCK(ddp);
|
||||
@ -163,9 +154,7 @@ ddp_shutdown(struct socket *so)
|
||||
struct ddpcb *ddp;
|
||||
|
||||
ddp = sotoddpcb(so);
|
||||
if (ddp == NULL) {
|
||||
return (EINVAL);
|
||||
}
|
||||
KASSERT(ddp != NULL, ("ddp_shutdown: ddp == NULL"));
|
||||
socantsendmore(so);
|
||||
return (0);
|
||||
}
|
||||
@ -178,9 +167,7 @@ ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
||||
int error = 0;
|
||||
|
||||
ddp = sotoddpcb(so);
|
||||
if (ddp == NULL) {
|
||||
return (EINVAL);
|
||||
}
|
||||
KASSERT(ddp != NULL, ("ddp_send: ddp == NULL"));
|
||||
|
||||
if (control && control->m_len) {
|
||||
return (EINVAL);
|
||||
@ -219,13 +206,12 @@ ddp_abort(struct socket *so)
|
||||
struct ddpcb *ddp;
|
||||
|
||||
ddp = sotoddpcb(so);
|
||||
if (ddp == NULL) {
|
||||
return (EINVAL);
|
||||
}
|
||||
KASSERT(ddp != NULL, ("ddp_abort: ddp == NULL"));
|
||||
DDP_LIST_XLOCK();
|
||||
DDP_LOCK(ddp);
|
||||
at_pcbdetach(so, ddp);
|
||||
DDP_LIST_XUNLOCK();
|
||||
/* XXXRW: Should be calling sotryfree() here? */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user