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

Function ng_socket_free_priv

freebsd/netgraph/ng_socket.c:664–687  ·  view source on GitHub ↗

* Remove a reference from node private data. */

Source from the content-addressed store, hash-verified

662 * Remove a reference from node private data.
663 */
664static void
665ng_socket_free_priv(struct ngsock *priv)
666{
667 mtx_assert(&priv->mtx, MA_OWNED);
668
669 priv->refs--;
670
671 if (priv->refs == 0) {
672 mtx_destroy(&priv->mtx);
673 hashdestroy(priv->hash, M_NETGRAPH_SOCK, priv->hmask);
674 free(priv, M_NETGRAPH_SOCK);
675 return;
676 }
677
678 if ((priv->refs == 1) && (priv->node != NULL)) {
679 node_p node = priv->node;
680
681 priv->node = NULL;
682 mtx_unlock(&priv->mtx);
683 NG_NODE_UNREF(node);
684 ng_rmnode_self(node);
685 } else
686 mtx_unlock(&priv->mtx);
687}
688
689/*
690 * Connect the data socket to a named control socket node.

Callers 2

ng_detach_commonFunction · 0.85
ngs_shutdownFunction · 0.85

Calls 5

mtx_assertFunction · 0.85
ng_rmnode_selfFunction · 0.70
hashdestroyFunction · 0.50
freeFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected