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

Function ng_rmnode

freebsd/netgraph/ng_base.c:714–786  ·  view source on GitHub ↗

* Forceably start the shutdown process on a node. Either call * its shutdown method, or do the default shutdown if there is * no type-specific method. * * We can only be called from a shutdown message, so we know we have * a writer lock, and therefore exclusive access. It also means * that we should not be on the work queue, but we check anyhow. * * Persistent node types must have a type-s

Source from the content-addressed store, hash-verified

712 * are rebooting.... etc.
713 */
714void
715ng_rmnode(node_p node, hook_p dummy1, void *dummy2, int dummy3)
716{
717 hook_p hook;
718
719 /* Check if it's already shutting down */
720 if ((node->nd_flags & NGF_CLOSING) != 0)
721 return;
722
723 if (node == &ng_deadnode) {
724 printf ("shutdown called on deadnode\n");
725 return;
726 }
727
728 /* Add an extra reference so it doesn't go away during this */
729 NG_NODE_REF(node);
730
731 /*
732 * Mark it invalid so any newcomers know not to try use it
733 * Also add our own mark so we can't recurse
734 * note that NGF_INVALID does not do this as it's also set during
735 * creation
736 */
737 node->nd_flags |= NGF_INVALID|NGF_CLOSING;
738
739 /* If node has its pre-shutdown method, then call it first*/
740 if (node->nd_type && node->nd_type->close)
741 (*node->nd_type->close)(node);
742
743 /* Notify all remaining connected nodes to disconnect */
744 while ((hook = LIST_FIRST(&node->nd_hooks)) != NULL)
745 ng_destroy_hook(hook);
746
747 /*
748 * Drain the input queue forceably.
749 * it has no hooks so what's it going to do, bleed on someone?
750 * Theoretically we came here from a queue entry that was added
751 * Just before the queue was closed, so it should be empty anyway.
752 * Also removes us from worklist if needed.
753 */
754 ng_flush_input_queue(node);
755
756 /* Ask the type if it has anything to do in this case */
757 if (node->nd_type && node->nd_type->shutdown) {
758 (*node->nd_type->shutdown)(node);
759 if (NG_NODE_IS_VALID(node)) {
760 /*
761 * Well, blow me down if the node code hasn't declared
762 * that it doesn't want to die.
763 * Presumably it is a persistent node.
764 * If we REALLY want it to go away,
765 * e.g. hardware going away,
766 * Our caller should set NGF_REALLY_DIE in nd_flags.
767 */
768 node->nd_flags &= ~(NGF_INVALID|NGF_CLOSING);
769 NG_NODE_UNREF(node); /* Assume they still have theirs */
770 return;
771 }

Callers 3

ng_mkpeerFunction · 0.70
ng_generic_msgFunction · 0.70
vnet_netgraph_uninitFunction · 0.70

Calls 4

ng_destroy_hookFunction · 0.70
ng_flush_input_queueFunction · 0.70
ng_unnameFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected