Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*


3246 
3247 /*
3248  * Called when refcount goes to 0, indicating that all references to this
3249  * node are gone.
3250  *
3251  * This does not unchain the action from the hash table.
3252  */
3253 void
3254 ipsec_action_free(ipsec_action_t *ap)
3255 {
3256         for (;;) {
3257                 ipsec_action_t *np = ap->ipa_next;
3258                 ASSERT(ap->ipa_refs == 0);
3259                 ASSERT(ap->ipa_hash.hash_pp == NULL);
3260                 kmem_cache_free(ipsec_action_cache, ap);
3261                 ap = np;
3262                 /* Inlined IPACT_REFRELE -- avoid recursion */
3263                 if (ap == NULL)
3264                         break;
3265                 membar_exit();
3266                 if (atomic_add_32_nv(&(ap)->ipa_refs, -1) != 0)
3267                         break;
3268                 /* End inlined IPACT_REFRELE */
3269         }
3270 }
3271 
3272 /*
3273  * Called when the action hash table goes away.
3274  *
3275  * The actions can be queued on an mblk with ipsec_in or
3276  * ipsec_out, hence the actions might still be around.
3277  * But we decrement ipa_refs here since we no longer have
3278  * a reference to the action from the hash table.
3279  */
3280 static void
3281 ipsec_action_free_table(ipsec_action_t *ap)
3282 {
3283         while (ap != NULL) {
3284                 ipsec_action_t *np = ap->ipa_next;
3285 
3286                 /* FIXME: remove? */




3246 
3247 /*
3248  * Called when refcount goes to 0, indicating that all references to this
3249  * node are gone.
3250  *
3251  * This does not unchain the action from the hash table.
3252  */
3253 void
3254 ipsec_action_free(ipsec_action_t *ap)
3255 {
3256         for (;;) {
3257                 ipsec_action_t *np = ap->ipa_next;
3258                 ASSERT(ap->ipa_refs == 0);
3259                 ASSERT(ap->ipa_hash.hash_pp == NULL);
3260                 kmem_cache_free(ipsec_action_cache, ap);
3261                 ap = np;
3262                 /* Inlined IPACT_REFRELE -- avoid recursion */
3263                 if (ap == NULL)
3264                         break;
3265                 membar_exit();
3266                 if (atomic_dec_32_nv(&(ap)->ipa_refs) != 0)
3267                         break;
3268                 /* End inlined IPACT_REFRELE */
3269         }
3270 }
3271 
3272 /*
3273  * Called when the action hash table goes away.
3274  *
3275  * The actions can be queued on an mblk with ipsec_in or
3276  * ipsec_out, hence the actions might still be around.
3277  * But we decrement ipa_refs here since we no longer have
3278  * a reference to the action from the hash table.
3279  */
3280 static void
3281 ipsec_action_free_table(ipsec_action_t *ap)
3282 {
3283         while (ap != NULL) {
3284                 ipsec_action_t *np = ap->ipa_next;
3285 
3286                 /* FIXME: remove? */