7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include <sys/fm/protocol.h>
30 #include <limits.h>
31
32 #include <fmd_alloc.h>
33 #include <fmd_subr.h>
34 #include <fmd_event.h>
35 #include <fmd_string.h>
36 #include <fmd_module.h>
37 #include <fmd_case.h>
38 #include <fmd_log.h>
39 #include <fmd_time.h>
40 #include <fmd_topo.h>
41 #include <fmd_ctl.h>
42
43 #include <fmd.h>
44
45 static void
46 fmd_event_nvwrap(fmd_event_impl_t *ep)
47 {
48 (void) nvlist_remove_all(ep->ev_nvl, FMD_EVN_TTL);
205 /*
206 * Perform any event type-specific cleanup activities, and then free
207 * the name-value pair list and underlying event data structure.
208 */
209 switch (ep->ev_type) {
210 case FMD_EVT_TIMEOUT:
211 fmd_free(ep->ev_data, sizeof (fmd_modtimer_t));
212 break;
213 case FMD_EVT_CLOSE:
214 case FMD_EVT_PUBLISH:
215 fmd_case_rele(ep->ev_data);
216 break;
217 case FMD_EVT_CTL:
218 fmd_ctl_fini(ep->ev_data);
219 break;
220 case FMD_EVT_TOPO:
221 fmd_topo_rele(ep->ev_data);
222 break;
223 }
224
225 if (ep->ev_nvl != NULL)
226 nvlist_free(ep->ev_nvl);
227
228 fmd_free(ep, sizeof (fmd_event_impl_t));
229 }
230
231 void
232 fmd_event_hold(fmd_event_t *e)
233 {
234 fmd_event_impl_t *ep = (fmd_event_impl_t *)e;
235
236 (void) pthread_mutex_lock(&ep->ev_lock);
237 ep->ev_refs++;
238 ASSERT(ep->ev_refs != 0);
239 (void) pthread_mutex_unlock(&ep->ev_lock);
240
241 if (ep->ev_type == FMD_EVT_CTL)
242 fmd_ctl_hold(ep->ev_data);
243 }
244
245 void
|
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include <sys/fm/protocol.h>
28 #include <limits.h>
29
30 #include <fmd_alloc.h>
31 #include <fmd_subr.h>
32 #include <fmd_event.h>
33 #include <fmd_string.h>
34 #include <fmd_module.h>
35 #include <fmd_case.h>
36 #include <fmd_log.h>
37 #include <fmd_time.h>
38 #include <fmd_topo.h>
39 #include <fmd_ctl.h>
40
41 #include <fmd.h>
42
43 static void
44 fmd_event_nvwrap(fmd_event_impl_t *ep)
45 {
46 (void) nvlist_remove_all(ep->ev_nvl, FMD_EVN_TTL);
203 /*
204 * Perform any event type-specific cleanup activities, and then free
205 * the name-value pair list and underlying event data structure.
206 */
207 switch (ep->ev_type) {
208 case FMD_EVT_TIMEOUT:
209 fmd_free(ep->ev_data, sizeof (fmd_modtimer_t));
210 break;
211 case FMD_EVT_CLOSE:
212 case FMD_EVT_PUBLISH:
213 fmd_case_rele(ep->ev_data);
214 break;
215 case FMD_EVT_CTL:
216 fmd_ctl_fini(ep->ev_data);
217 break;
218 case FMD_EVT_TOPO:
219 fmd_topo_rele(ep->ev_data);
220 break;
221 }
222
223 nvlist_free(ep->ev_nvl);
224
225 fmd_free(ep, sizeof (fmd_event_impl_t));
226 }
227
228 void
229 fmd_event_hold(fmd_event_t *e)
230 {
231 fmd_event_impl_t *ep = (fmd_event_impl_t *)e;
232
233 (void) pthread_mutex_lock(&ep->ev_lock);
234 ep->ev_refs++;
235 ASSERT(ep->ev_refs != 0);
236 (void) pthread_mutex_unlock(&ep->ev_lock);
237
238 if (ep->ev_type == FMD_EVT_CTL)
239 fmd_ctl_hold(ep->ev_data);
240 }
241
242 void
|