MCPcopy Create free account
hub / github.com/F-Stack/f-stack / uipc_accept

Function uipc_accept

freebsd/kern/uipc_usrreq.c:488–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488static int
489uipc_accept(struct socket *so, struct sockaddr **nam)
490{
491 struct unpcb *unp, *unp2;
492 const struct sockaddr *sa;
493
494 /*
495 * Pass back name of connected socket, if it was bound and we are
496 * still connected (our peer may have closed already!).
497 */
498 unp = sotounpcb(so);
499 KASSERT(unp != NULL, ("uipc_accept: unp == NULL"));
500
501 *nam = malloc(sizeof(struct sockaddr_un), M_SONAME, M_WAITOK);
502 UNP_PCB_LOCK(unp);
503 unp2 = unp_pcb_lock_peer(unp);
504 if (unp2 != NULL && unp2->unp_addr != NULL)
505 sa = (struct sockaddr *)unp2->unp_addr;
506 else
507 sa = &sun_noname;
508 bcopy(sa, *nam, sa->sa_len);
509 if (unp2 != NULL)
510 unp_pcb_unlock_pair(unp, unp2);
511 else
512 UNP_PCB_UNLOCK(unp);
513 return (0);
514}
515
516static int
517uipc_attach(struct socket *so, int proto, struct thread *td)

Callers

nothing calls this directly

Calls 3

mallocFunction · 0.85
unp_pcb_lock_peerFunction · 0.85
unp_pcb_unlock_pairFunction · 0.85

Tested by

no test coverage detected