Purge node queue. Called on node shutdown. */
| 2176 | |
| 2177 | /* Purge node queue. Called on node shutdown. */ |
| 2178 | static void |
| 2179 | ng_flush_input_queue(node_p node) |
| 2180 | { |
| 2181 | struct ng_queue *ngq = &node->nd_input_queue; |
| 2182 | item_p item; |
| 2183 | |
| 2184 | NG_QUEUE_LOCK(ngq); |
| 2185 | while ((item = STAILQ_FIRST(&ngq->queue)) != NULL) { |
| 2186 | STAILQ_REMOVE_HEAD(&ngq->queue, el_next); |
| 2187 | if (STAILQ_EMPTY(&ngq->queue)) |
| 2188 | atomic_clear_int(&ngq->q_flags, OP_PENDING); |
| 2189 | NG_QUEUE_UNLOCK(ngq); |
| 2190 | |
| 2191 | /* If the item is supplying a callback, call it with an error */ |
| 2192 | if (item->apply != NULL) { |
| 2193 | if (item->depth == 1) |
| 2194 | item->apply->error = ENOENT; |
| 2195 | if (refcount_release(&item->apply->refs)) { |
| 2196 | (*item->apply->apply)(item->apply->context, |
| 2197 | item->apply->error); |
| 2198 | } |
| 2199 | } |
| 2200 | NG_FREE_ITEM(item); |
| 2201 | NG_QUEUE_LOCK(ngq); |
| 2202 | } |
| 2203 | NG_QUEUE_UNLOCK(ngq); |
| 2204 | } |
| 2205 | #endif |
| 2206 | |
| 2207 | /*********************************************************************** |
no test coverage detected