* Release a queue entry */
| 3026 | * Release a queue entry |
| 3027 | */ |
| 3028 | void |
| 3029 | ng_free_item(item_p item) |
| 3030 | { |
| 3031 | /* |
| 3032 | * The item may hold resources on its own. We need to free |
| 3033 | * these before we can free the item. What they are depends upon |
| 3034 | * what kind of item it is. it is important that nodes zero |
| 3035 | * out pointers to resources that they remove from the item |
| 3036 | * or we release them again here. |
| 3037 | */ |
| 3038 | switch (item->el_flags & NGQF_TYPE) { |
| 3039 | case NGQF_DATA: |
| 3040 | /* If we have an mbuf still attached.. */ |
| 3041 | NG_FREE_M(_NGI_M(item)); |
| 3042 | break; |
| 3043 | case NGQF_MESG: |
| 3044 | _NGI_RETADDR(item) = 0; |
| 3045 | NG_FREE_MSG(_NGI_MSG(item)); |
| 3046 | break; |
| 3047 | case NGQF_FN: |
| 3048 | case NGQF_FN2: |
| 3049 | /* nothing to free really, */ |
| 3050 | _NGI_FN(item) = NULL; |
| 3051 | _NGI_ARG1(item) = NULL; |
| 3052 | _NGI_ARG2(item) = 0; |
| 3053 | break; |
| 3054 | } |
| 3055 | /* If we still have a node or hook referenced... */ |
| 3056 | _NGI_CLR_NODE(item); |
| 3057 | _NGI_CLR_HOOK(item); |
| 3058 | |
| 3059 | #ifdef NETGRAPH_DEBUG |
| 3060 | mtx_lock(&ngq_mtx); |
| 3061 | TAILQ_REMOVE(&ng_itemlist, item, all); |
| 3062 | allocated--; |
| 3063 | mtx_unlock(&ngq_mtx); |
| 3064 | #endif |
| 3065 | uma_zfree(((item->el_flags & NGQF_TYPE) == NGQF_DATA) ? |
| 3066 | ng_qdzone : ng_qzone, item); |
| 3067 | } |
| 3068 | |
| 3069 | /* |
| 3070 | * Change type of the queue entry. |
no test coverage detected