MCPcopy Index your code
hub / github.com/F-Stack/f-stack / sodealloc

Function sodealloc

freebsd/kern/uipc_socket.c:459–499  ·  view source on GitHub ↗

* Free the storage associated with a socket at the socket layer, tear down * locks, labels, etc. All protocol state is assumed already to have been * torn down (and possibly never set up) by the caller. */

Source from the content-addressed store, hash-verified

457 * torn down (and possibly never set up) by the caller.
458 */
459static void
460sodealloc(struct socket *so)
461{
462
463 KASSERT(so->so_count == 0, ("sodealloc(): so_count %d", so->so_count));
464 KASSERT(so->so_pcb == NULL, ("sodealloc(): so_pcb != NULL"));
465
466 mtx_lock(&so_global_mtx);
467 so->so_gencnt = ++so_gencnt;
468 --numopensockets; /* Could be below, but faster here. */
469#ifdef VIMAGE
470 VNET_ASSERT(so->so_vnet != NULL, ("%s:%d so_vnet is NULL, so=%p",
471 __func__, __LINE__, so));
472 so->so_vnet->vnet_sockcnt--;
473#endif
474 mtx_unlock(&so_global_mtx);
475#ifdef MAC
476 mac_socket_destroy(so);
477#endif
478 hhook_run_socket(so, NULL, HHOOK_SOCKET_CLOSE);
479
480 crfree(so->so_cred);
481 khelp_destroy_osd(&so->osd);
482 if (SOLISTENING(so)) {
483 if (so->sol_accept_filter != NULL)
484 accept_filt_setopt(so, NULL);
485 } else {
486 if (so->so_rcv.sb_hiwat)
487 (void)chgsbsize(so->so_cred->cr_uidinfo,
488 &so->so_rcv.sb_hiwat, 0, RLIM_INFINITY);
489 if (so->so_snd.sb_hiwat)
490 (void)chgsbsize(so->so_cred->cr_uidinfo,
491 &so->so_snd.sb_hiwat, 0, RLIM_INFINITY);
492 sx_destroy(&so->so_snd.sb_sx);
493 sx_destroy(&so->so_rcv.sb_sx);
494 SOCKBUF_LOCK_DESTROY(&so->so_snd);
495 SOCKBUF_LOCK_DESTROY(&so->so_rcv);
496 }
497 mtx_destroy(&so->so_lock);
498 uma_zfree(socket_zone, so);
499}
500
501/*
502 * socreate returns a socket with a ref count of 1. The socket should be

Callers 4

socreateFunction · 0.85
uipc_socket.cFile · 0.85
sopeeloffFunction · 0.85
sofreeFunction · 0.85

Calls 10

mac_socket_destroyFunction · 0.85
hhook_run_socketFunction · 0.85
khelp_destroy_osdFunction · 0.85
accept_filt_setoptFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
crfreeFunction · 0.70
chgsbsizeFunction · 0.70
sx_destroyFunction · 0.70
uma_zfreeFunction · 0.50

Tested by

no test coverage detected