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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/neti_impl.c
          +++ new/usr/src/uts/common/io/neti_impl.c
↓ open down ↓ 126 lines elided ↑ open up ↑
 127  127  
 128  128          ASSERT(protocol != NULL);
 129  129  
 130  130          nts = net_getnetistackbyid(netid);
 131  131          if (nts == NULL)
 132  132                  return (NULL);
 133  133  
 134  134          mutex_enter(&nts->nts_lock);
 135  135          nd = net_find(protocol, nts);
 136  136          if (nd != NULL)
 137      -                atomic_add_32((uint_t *)&nd->netd_refcnt, 1);
      137 +                atomic_inc_32((uint_t *)&nd->netd_refcnt);
 138  138          mutex_exit(&nts->nts_lock);
 139  139          return (nd);
 140  140  }
 141  141  
 142  142  /*
 143  143   * Note: the man page specifies "returns -1 if the value passed in is unknown
 144  144   * to this framework".  We are not doing a lookup in this function, just a
 145  145   * simply add to the netd_refcnt of the net_handle_t passed in, so -1 is never a
 146  146   * return value.
 147  147   */
↓ open down ↓ 2 lines elided ↑ open up ↑
 150  150  {
 151  151  
 152  152          ASSERT(info->netd_refcnt > 0);
 153  153          /*
 154  154           * Is this safe? No hold on nts_lock? Consider that if the caller
 155  155           * of net_protocol_release() is going to free this structure then
 156  156           * it is now the only owner (refcnt==1) and it will have been
 157  157           * removed from the nts_netd_head list on the neti_stack_t from a
 158  158           * call to net_protocol_unregister already, so it is thus an orphan.
 159  159           */
 160      -        if (atomic_add_32_nv((uint_t *)&info->netd_refcnt, -1) == 0) {
      160 +        if (atomic_dec_32_nv((uint_t *)&info->netd_refcnt) == 0) {
 161  161                  ASSERT(info->netd_hooks == NULL);
 162  162                  ASSERT(info->netd_stack == NULL);
 163  163                  kmem_free(info, sizeof (struct net_data));
 164  164          }
 165  165  
 166  166          return (0);
 167  167  }
 168  168  
 169  169  net_handle_t
 170  170  net_protocol_walk(netid_t netid, net_handle_t info)
↓ open down ↓ 23 lines elided ↑ open up ↑
 194  194                  }
 195  195  
 196  196                  if (n == info)
 197  197                          found = B_TRUE;
 198  198          }
 199  199  
 200  200          if (info != NULL)
 201  201                  (void) net_protocol_release(info);
 202  202  
 203  203          if (n != NULL)
 204      -                atomic_add_32((uint_t *)&n->netd_refcnt, 1);
      204 +                atomic_inc_32((uint_t *)&n->netd_refcnt);
 205  205  
 206  206          mutex_exit(&nts->nts_lock);
 207  207  
 208  208          return (n);
 209  209  }
 210  210  
 211  211  /*
 212  212   * Public accessor functions
 213  213   */
 214  214  int
↓ open down ↓ 466 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX