Print this page
6659 nvlist_free(NULL) is a no-op


1147 
1148         eg = zone_getspecific(evch_zone_key, curproc->p_zone);
1149         ASSERT(eg != NULL);
1150 
1151         mutex_enter(&eg->evch_list_lock);
1152         mutex_enter(&chp->ch_mutex);
1153         ASSERT(chp->ch_bindings > 0);
1154         chp->ch_bindings--;
1155         kmem_free(bp, sizeof (evch_bind_t));
1156         if (chp->ch_bindings == 0 && evch_dl_getnum(&chp->ch_subscr) == 0 &&
1157             (chp->ch_nevents == 0 || chp->ch_holdpend != CH_HOLD_PEND_INDEF)) {
1158                 /*
1159                  * No more bindings and no persistent subscriber(s).  If there
1160                  * are no events in the channel then destroy the channel;
1161                  * otherwise destroy the channel only if we're not holding
1162                  * pending events indefinitely.
1163                  */
1164                 mutex_exit(&chp->ch_mutex);
1165                 evch_dl_del(&eg->evch_list, &chp->ch_link);
1166                 evch_evq_destroy(chp->ch_queue);
1167                 if (chp->ch_propnvl)
1168                         nvlist_free(chp->ch_propnvl);
1169                 mutex_destroy(&chp->ch_mutex);
1170                 mutex_destroy(&chp->ch_pubmx);
1171                 cv_destroy(&chp->ch_pubcv);
1172                 kmem_free(chp->ch_name, chp->ch_namelen);
1173                 kmem_free(chp, sizeof (evch_chan_t));
1174         } else
1175                 mutex_exit(&chp->ch_mutex);
1176         mutex_exit(&eg->evch_list_lock);
1177 }
1178 
1179 static int
1180 wildcard_count(const char *class)
1181 {
1182         int count = 0;
1183         char c;
1184 
1185         if (class == NULL)
1186                 return (0);
1187 


1555                 subp->sb_nevents = EVCH_EVQ_EVCOUNT(sdp->sd_queue);
1556                 subp->sb_evhwm = EVCH_EVQ_HIGHWM(sdp->sd_queue);
1557                 subp->sb_persist = sdp->sd_persist;
1558                 subp->sb_status = evch_evq_status(sdp->sd_queue);
1559                 subp->sb_active = sdp->sd_active;
1560                 subp->sb_dump = sdp->sd_dump;
1561                 bcopy(sdp->sd_ident, subp->sb_strings, idlen);
1562                 cpaddr += len;
1563         }
1564         mutex_exit(&eg->evch_list_lock);
1565         return (chdlen + buflen);
1566 }
1567 
1568 static void
1569 evch_chsetpropnvl(evch_bind_t *bp, nvlist_t *nvl)
1570 {
1571         evch_chan_t *chp = bp->bd_channel;
1572 
1573         mutex_enter(&chp->ch_mutex);
1574 
1575         if (chp->ch_propnvl)
1576                 nvlist_free(chp->ch_propnvl);
1577 
1578         chp->ch_propnvl = nvl;
1579         chp->ch_propnvlgen++;
1580 
1581         mutex_exit(&chp->ch_mutex);
1582 }
1583 
1584 static int
1585 evch_chgetpropnvl(evch_bind_t *bp, nvlist_t **nvlp, int64_t *genp)
1586 {
1587         evch_chan_t *chp = bp->bd_channel;
1588         int rc = 0;
1589 
1590         mutex_enter(&chp->ch_mutex);
1591 
1592         if (chp->ch_propnvl != NULL)
1593                 rc = (nvlist_dup(chp->ch_propnvl, nvlp, 0) == 0) ? 0 : ENOMEM;
1594         else
1595                 *nvlp = NULL;   /* rc still 0 */




1147 
1148         eg = zone_getspecific(evch_zone_key, curproc->p_zone);
1149         ASSERT(eg != NULL);
1150 
1151         mutex_enter(&eg->evch_list_lock);
1152         mutex_enter(&chp->ch_mutex);
1153         ASSERT(chp->ch_bindings > 0);
1154         chp->ch_bindings--;
1155         kmem_free(bp, sizeof (evch_bind_t));
1156         if (chp->ch_bindings == 0 && evch_dl_getnum(&chp->ch_subscr) == 0 &&
1157             (chp->ch_nevents == 0 || chp->ch_holdpend != CH_HOLD_PEND_INDEF)) {
1158                 /*
1159                  * No more bindings and no persistent subscriber(s).  If there
1160                  * are no events in the channel then destroy the channel;
1161                  * otherwise destroy the channel only if we're not holding
1162                  * pending events indefinitely.
1163                  */
1164                 mutex_exit(&chp->ch_mutex);
1165                 evch_dl_del(&eg->evch_list, &chp->ch_link);
1166                 evch_evq_destroy(chp->ch_queue);

1167                 nvlist_free(chp->ch_propnvl);
1168                 mutex_destroy(&chp->ch_mutex);
1169                 mutex_destroy(&chp->ch_pubmx);
1170                 cv_destroy(&chp->ch_pubcv);
1171                 kmem_free(chp->ch_name, chp->ch_namelen);
1172                 kmem_free(chp, sizeof (evch_chan_t));
1173         } else
1174                 mutex_exit(&chp->ch_mutex);
1175         mutex_exit(&eg->evch_list_lock);
1176 }
1177 
1178 static int
1179 wildcard_count(const char *class)
1180 {
1181         int count = 0;
1182         char c;
1183 
1184         if (class == NULL)
1185                 return (0);
1186 


1554                 subp->sb_nevents = EVCH_EVQ_EVCOUNT(sdp->sd_queue);
1555                 subp->sb_evhwm = EVCH_EVQ_HIGHWM(sdp->sd_queue);
1556                 subp->sb_persist = sdp->sd_persist;
1557                 subp->sb_status = evch_evq_status(sdp->sd_queue);
1558                 subp->sb_active = sdp->sd_active;
1559                 subp->sb_dump = sdp->sd_dump;
1560                 bcopy(sdp->sd_ident, subp->sb_strings, idlen);
1561                 cpaddr += len;
1562         }
1563         mutex_exit(&eg->evch_list_lock);
1564         return (chdlen + buflen);
1565 }
1566 
1567 static void
1568 evch_chsetpropnvl(evch_bind_t *bp, nvlist_t *nvl)
1569 {
1570         evch_chan_t *chp = bp->bd_channel;
1571 
1572         mutex_enter(&chp->ch_mutex);
1573 

1574         nvlist_free(chp->ch_propnvl);
1575 
1576         chp->ch_propnvl = nvl;
1577         chp->ch_propnvlgen++;
1578 
1579         mutex_exit(&chp->ch_mutex);
1580 }
1581 
1582 static int
1583 evch_chgetpropnvl(evch_bind_t *bp, nvlist_t **nvlp, int64_t *genp)
1584 {
1585         evch_chan_t *chp = bp->bd_channel;
1586         int rc = 0;
1587 
1588         mutex_enter(&chp->ch_mutex);
1589 
1590         if (chp->ch_propnvl != NULL)
1591                 rc = (nvlist_dup(chp->ch_propnvl, nvlp, 0) == 0) ? 0 : ENOMEM;
1592         else
1593                 *nvlp = NULL;   /* rc still 0 */