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

Function ng_rmnode

lib/ff_ng_base.c:718–792  ·  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

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

Callers 3

ng_mkpeerFunction · 0.70
ng_generic_msgFunction · 0.70
vnet_netgraph_uninitFunction · 0.70

Calls 4

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

Tested by

no test coverage detected