* Release a queue entry */
| 3002 | * Release a queue entry |
| 3003 | */ |
| 3004 | void |
| 3005 | ng_free_item(item_p item) |
| 3006 | { |
| 3007 | /* |
| 3008 | * The item may hold resources on its own. We need to free |
| 3009 | * these before we can free the item. What they are depends upon |
| 3010 | * what kind of item it is. it is important that nodes zero |
| 3011 | * out pointers to resources that they remove from the item |
| 3012 | * or we release them again here. |
| 3013 | */ |
| 3014 | switch (item->el_flags & NGQF_TYPE) { |
| 3015 | case NGQF_DATA: |
| 3016 | /* If we have an mbuf still attached.. */ |
| 3017 | NG_FREE_M(_NGI_M(item)); |
| 3018 | break; |
| 3019 | case NGQF_MESG: |
| 3020 | _NGI_RETADDR(item) = 0; |
| 3021 | NG_FREE_MSG(_NGI_MSG(item)); |
| 3022 | break; |
| 3023 | case NGQF_FN: |
| 3024 | case NGQF_FN2: |
| 3025 | /* nothing to free really, */ |
| 3026 | _NGI_FN(item) = NULL; |
| 3027 | _NGI_ARG1(item) = NULL; |
| 3028 | _NGI_ARG2(item) = 0; |
| 3029 | break; |
| 3030 | } |
| 3031 | /* If we still have a node or hook referenced... */ |
| 3032 | _NGI_CLR_NODE(item); |
| 3033 | _NGI_CLR_HOOK(item); |
| 3034 | |
| 3035 | #ifdef NETGRAPH_DEBUG |
| 3036 | mtx_lock(&ngq_mtx); |
| 3037 | TAILQ_REMOVE(&ng_itemlist, item, all); |
| 3038 | allocated--; |
| 3039 | mtx_unlock(&ngq_mtx); |
| 3040 | #endif |
| 3041 | uma_zfree(((item->el_flags & NGQF_TYPE) == NGQF_DATA) ? |
| 3042 | ng_qdzone : ng_qzone, item); |
| 3043 | } |
| 3044 | |
| 3045 | /* |
| 3046 | * Change type of the queue entry. |
no test coverage detected