Purge node queue. Called on node shutdown. */
| 2169 | |
| 2170 | /* Purge node queue. Called on node shutdown. */ |
| 2171 | static void |
| 2172 | ng_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. |
no test coverage detected