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

Function ng_flush_input_queue

freebsd/netgraph/ng_base.c:2171–2197  ·  view source on GitHub ↗

Purge node queue. Called on node shutdown. */

Source from the content-addressed store, hash-verified

2169
2170/* Purge node queue. Called on node shutdown. */
2171static void
2172ng_flush_input_queue(node_p node)
2173{
2174 struct ng_queue *ngq = &node->nd_input_queue;
2175 item_p item;
2176
2177 NG_QUEUE_LOCK(ngq);
2178 while ((item = STAILQ_FIRST(&ngq->queue)) != NULL) {
2179 STAILQ_REMOVE_HEAD(&ngq->queue, el_next);
2180 if (STAILQ_EMPTY(&ngq->queue))
2181 atomic_clear_int(&ngq->q_flags, OP_PENDING);
2182 NG_QUEUE_UNLOCK(ngq);
2183
2184 /* If the item is supplying a callback, call it with an error */
2185 if (item->apply != NULL) {
2186 if (item->depth == 1)
2187 item->apply->error = ENOENT;
2188 if (refcount_release(&item->apply->refs)) {
2189 (*item->apply->apply)(item->apply->context,
2190 item->apply->error);
2191 }
2192 }
2193 NG_FREE_ITEM(item);
2194 NG_QUEUE_LOCK(ngq);
2195 }
2196 NG_QUEUE_UNLOCK(ngq);
2197}
2198
2199/***********************************************************************
2200* Externally visible method for sending or queueing messages or data.

Callers 1

ng_rmnodeFunction · 0.70

Calls 1

refcount_releaseFunction · 0.85

Tested by

no test coverage detected