Lines Matching refs:shp

65 static int cleanup_id(sysevent_handle_t *shp, uint32_t id, int type);
759 subscriber_event_handler(sysevent_handle_t *shp) in subscriber_event_handler() argument
764 sub_info = (subscriber_priv_t *)SH_PRIV_DATA(shp); in subscriber_event_handler()
772 while (sub_info->sp_evq_head == NULL && SH_BOUND(shp)) { in subscriber_event_handler()
785 if (!SH_BOUND(shp)) { in subscriber_event_handler()
817 sysevent_handle_t *shp; in event_deliver_service() local
831 shp = (sysevent_handle_t *)cookie; in event_deliver_service()
832 if (shp == NULL) { in event_deliver_service()
841 if (mutex_trylock(SH_LOCK(shp)) != 0) { in event_deliver_service()
846 if (!SH_BOUND(shp)) { in event_deliver_service()
848 (void) mutex_unlock(SH_LOCK(shp)); in event_deliver_service()
852 sub_info = (subscriber_priv_t *)SH_PRIV_DATA(shp); in event_deliver_service()
855 (void) mutex_unlock(SH_LOCK(shp)); in event_deliver_service()
863 (void) mutex_unlock(SH_LOCK(shp)); in event_deliver_service()
875 (void) mutex_unlock(SH_LOCK(shp)); in event_deliver_service()
890 (void) mutex_unlock(SH_LOCK(shp)); in event_deliver_service()
990 update_kernel_registration(sysevent_handle_t *shp, int update_type, in update_kernel_registration() argument
994 char *channel_name = SH_CHANNEL_NAME(shp); in update_kernel_registration()
1076 dealloc_subscribers(sysevent_handle_t *shp) in dealloc_subscribers() argument
1082 sub = SH_SUBSCRIBER(shp, i); in dealloc_subscribers()
1087 SH_SUBSCRIBER(shp, i) = NULL; in dealloc_subscribers()
1093 alloc_subscriber(sysevent_handle_t *shp, uint32_t sub_id, int oflag) in alloc_subscriber() argument
1098 if (SH_SUBSCRIBER(shp, sub_id) != NULL) { in alloc_subscriber()
1109 SH_CHANNEL_PATH(shp), sub_id) >= MAXPATHLEN) { in alloc_subscriber()
1121 SH_SUBSCRIBER(shp, sub_id) = sub; in alloc_subscriber()
1172 cache_find_class(sysevent_handle_t *shp, char *class) in cache_find_class() argument
1176 class_lst_t **class_hash = SH_CLASS_HASH(shp); in cache_find_class()
1227 cache_insert_class(sysevent_handle_t *shp, char *class, in cache_insert_class() argument
1235 (void) cache_insert_subclass(SH_CLASS_HASH(shp)[0], in cache_insert_class()
1241 if ((c_list = cache_find_class(shp, class)) == NULL) { in cache_insert_class()
1267 c_list->cl_next = SH_CLASS_HASH(shp)[CLASS_HASH(class)]; in cache_insert_class()
1268 SH_CLASS_HASH(shp)[CLASS_HASH(class)] = c_list; in cache_insert_class() local
1281 cache_remove_all_class(sysevent_handle_t *shp, uint32_t sub_id) in cache_remove_all_class() argument
1288 c_list = SH_CLASS_HASH(shp)[i]; in cache_remove_all_class()
1301 cache_remove_class(sysevent_handle_t *shp, char *class, uint32_t sub_id) in cache_remove_class() argument
1307 cache_remove_all_class(shp, sub_id); in cache_remove_class()
1311 if ((c_list = cache_find_class(shp, class)) == NULL) { in cache_remove_class()
1323 free_cached_registration(sysevent_handle_t *shp) in free_cached_registration() argument
1330 clist = SH_CLASS_HASH(shp)[i]; in free_cached_registration()
1344 SH_CLASS_HASH(shp)[i] = NULL; in free_cached_registration() local
1349 create_cached_registration(sysevent_handle_t *shp, in create_cached_registration() argument
1363 if ((nvl = get_kernel_registration(SH_CHANNEL_NAME(shp), i)) in create_cached_registration()
1438 if (alloc_subscriber(shp, j, 1) != 0) { in create_cached_registration()
1462 dealloc_subscribers(shp); in create_cached_registration()
1463 free_cached_registration(shp); in create_cached_registration()
1487 sysevent_handle_t *shp; in cache_update_service() local
1497 shp = (sysevent_handle_t *)cookie; in cache_update_service()
1502 (void) mutex_lock(SH_LOCK(shp)); in cache_update_service()
1507 cache_remove_class(shp, (char *)class, in cache_update_service()
1512 sub = SH_SUBSCRIBER(shp, sub_id); in cache_update_service()
1518 cache_remove_class(shp, EC_ALL, sub_id); in cache_update_service()
1519 SH_SUBSCRIBER(shp, sub_id) = NULL; in cache_update_service()
1525 if (alloc_subscriber(shp, sub_id, 0) != 0) { in cache_update_service()
1532 if (SH_SUBSCRIBER(shp, sub_id) == NULL) { in cache_update_service()
1555 ret = cache_insert_class(shp, class, in cache_update_service()
1558 cache_remove_class(shp, class, sub_id); in cache_update_service()
1569 sysevent_cleanup_subscribers(shp); in cache_update_service()
1575 (void) mutex_unlock(SH_LOCK(shp)); in cache_update_service()
1591 sysevent_send_event(sysevent_handle_t *shp, sysevent_t *ev) in sysevent_send_event() argument
1607 (void) mutex_lock(SH_LOCK(shp)); in sysevent_send_event()
1612 if (!SH_BOUND(shp)) { in sysevent_send_event()
1613 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_send_event()
1620 cache_find_class(shp, EC_ALL), EC_SUB_ALL); in sysevent_send_event()
1624 cache_find_class(shp, event_class), EC_SUB_ALL); in sysevent_send_event()
1631 cache_find_class(shp, event_class), event_subclass); in sysevent_send_event()
1644 sub = SH_SUBSCRIBER(shp, i); in sysevent_send_event()
1712 sysevent_cleanup_subscribers(shp); in sysevent_send_event()
1713 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_send_event()
1718 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_send_event()
1740 sysevent_handle_t *shp; in sysevent_open_channel_common() local
1772 shp = calloc(1, sizeof (sysevent_impl_hdl_t)); in sysevent_open_channel_common()
1773 if (shp == NULL) { in sysevent_open_channel_common()
1778 SH_CHANNEL_NAME(shp) = NULL; in sysevent_open_channel_common()
1779 SH_CHANNEL_PATH(shp) = strdup(channel_path); in sysevent_open_channel_common()
1780 if (SH_CHANNEL_PATH(shp) == NULL) { in sysevent_open_channel_common()
1781 free(shp); in sysevent_open_channel_common()
1787 begin_path = SH_CHANNEL_PATH(shp); in sysevent_open_channel_common()
1791 SH_CHANNEL_NAME(shp) = begin_path; in sysevent_open_channel_common()
1794 if (update_kernel_registration(shp, 0, in sysevent_open_channel_common()
1797 SH_CHANNEL_NAME(shp)); in sysevent_open_channel_common()
1798 free(SH_CHANNEL_PATH(shp)); in sysevent_open_channel_common()
1799 free(shp); in sysevent_open_channel_common()
1804 (void) mutex_init(SH_LOCK(shp), USYNC_THREAD, NULL); in sysevent_open_channel_common()
1806 return (shp); in sysevent_open_channel_common()
1888 sysevent_close_channel(sysevent_handle_t *shp) in sysevent_close_channel() argument
1893 if (shp == NULL) { in sysevent_close_channel()
1897 (void) mutex_lock(SH_LOCK(shp)); in sysevent_close_channel()
1898 if (SH_BOUND(shp)) { in sysevent_close_channel()
1899 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_close_channel()
1900 if (SH_TYPE(shp) == PUBLISHER) in sysevent_close_channel()
1901 sysevent_unbind_publisher(shp); in sysevent_close_channel()
1902 else if (SH_TYPE(shp) == SUBSCRIBER) in sysevent_close_channel()
1903 sysevent_unbind_subscriber(shp); in sysevent_close_channel()
1904 (void) mutex_lock(SH_LOCK(shp)); in sysevent_close_channel()
1907 (void) update_kernel_registration(shp, 0, in sysevent_close_channel()
1909 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_close_channel()
1911 free(SH_CHANNEL_PATH(shp)); in sysevent_close_channel()
1912 free(shp); in sysevent_close_channel()
1920 sysevent_bind_publisher(sysevent_handle_t *shp) in sysevent_bind_publisher() argument
1929 if (shp == NULL) { in sysevent_bind_publisher()
1934 (void) mutex_lock(SH_LOCK(shp)); in sysevent_bind_publisher()
1935 if (SH_BOUND(shp)) { in sysevent_bind_publisher()
1936 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_publisher()
1943 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_publisher()
1947 SH_PRIV_DATA(shp) = (void *)pub; in sysevent_bind_publisher()
1950 SH_CHANNEL_PATH(shp), REG_DOOR) >= MAXPATHLEN) { in sysevent_bind_publisher()
1952 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_publisher()
1956 if ((SH_DOOR_NAME(shp) = strdup(door_name)) == NULL) { in sysevent_bind_publisher()
1958 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_publisher()
1964 if (stat(SH_DOOR_NAME(shp), &reg_stat) != 0) { in sysevent_bind_publisher()
1974 if (unlink(SH_DOOR_NAME(shp)) != 0) in sysevent_bind_publisher()
1976 SH_DOOR_NAME(shp)); in sysevent_bind_publisher()
1979 fd = open(SH_DOOR_NAME(shp), O_CREAT|O_RDWR, in sysevent_bind_publisher()
1989 if ((SH_DOOR_DESC(shp) = door_create(cache_update_service, in sysevent_bind_publisher()
1990 (void *)shp, DOOR_REFUSE_DESC | DOOR_NO_CANCEL)) == -1) { in sysevent_bind_publisher()
1997 (void) fdetach(SH_DOOR_NAME(shp)); in sysevent_bind_publisher()
1998 if (fattach(SH_DOOR_DESC(shp), SH_DOOR_NAME(shp)) != 0) { in sysevent_bind_publisher()
2001 SH_DOOR_NAME(shp)); in sysevent_bind_publisher()
2007 if (update_kernel_registration(shp, PUBLISHER, in sysevent_bind_publisher()
2013 SH_ID(shp) = pub_id; in sysevent_bind_publisher()
2014 SH_BOUND(shp) = 1; in sysevent_bind_publisher()
2015 SH_TYPE(shp) = PUBLISHER; in sysevent_bind_publisher()
2019 if (create_cached_registration(shp, SH_CLASS_HASH(shp)) != 0) { in sysevent_bind_publisher()
2020 (void) update_kernel_registration(shp, in sysevent_bind_publisher()
2027 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_publisher()
2032 SH_BOUND(shp) = 0; in sysevent_bind_publisher()
2033 (void) door_revoke(SH_DOOR_DESC(shp)); in sysevent_bind_publisher()
2034 (void) fdetach(SH_DOOR_NAME(shp)); in sysevent_bind_publisher()
2035 free(SH_DOOR_NAME(shp)); in sysevent_bind_publisher()
2038 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_publisher()
2097 sysevent_bind_subscriber_cmn(sysevent_handle_t *shp, in sysevent_bind_subscriber_cmn() argument
2110 if (shp == NULL || event_handler == NULL) { in sysevent_bind_subscriber_cmn()
2115 (void) mutex_lock(SH_LOCK(shp)); in sysevent_bind_subscriber_cmn()
2116 if (SH_BOUND(shp)) { in sysevent_bind_subscriber_cmn()
2118 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_subscriber_cmn()
2125 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_subscriber_cmn()
2130 SH_CHANNEL_PATH(shp), REG_DOOR) >= MAXPATHLEN) { in sysevent_bind_subscriber_cmn()
2133 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_subscriber_cmn()
2140 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_subscriber_cmn()
2148 if (update_kernel_registration(shp, SUBSCRIBER, in sysevent_bind_subscriber_cmn()
2153 SH_ID(shp) = sub_id; in sysevent_bind_subscriber_cmn()
2156 SH_CHANNEL_PATH(shp), sub_id) >= MAXPATHLEN) { in sysevent_bind_subscriber_cmn()
2160 if ((SH_DOOR_NAME(shp) = strdup(door_name)) == NULL) { in sysevent_bind_subscriber_cmn()
2168 if (unlink(SH_DOOR_NAME(shp)) != 0) in sysevent_bind_subscriber_cmn()
2170 SH_DOOR_NAME(shp)); in sysevent_bind_subscriber_cmn()
2172 fd = open(SH_DOOR_NAME(shp), O_CREAT|O_RDWR, S_IREAD|S_IWRITE); in sysevent_bind_subscriber_cmn()
2184 SH_DOOR_DESC(shp) = door_create(event_deliver_service, in sysevent_bind_subscriber_cmn()
2185 (void *)shp, DOOR_REFUSE_DESC | DOOR_NO_CANCEL); in sysevent_bind_subscriber_cmn()
2187 SH_DOOR_DESC(shp) = door_xcreate(event_deliver_service, in sysevent_bind_subscriber_cmn()
2188 (void *)shp, in sysevent_bind_subscriber_cmn()
2194 if (SH_DOOR_DESC(shp) == -1) { in sysevent_bind_subscriber_cmn()
2201 (void) fdetach(SH_DOOR_NAME(shp)); in sysevent_bind_subscriber_cmn()
2202 if (fattach(SH_DOOR_DESC(shp), SH_DOOR_NAME(shp)) != 0) { in sysevent_bind_subscriber_cmn()
2211 (void) update_kernel_registration(shp, SUBSCRIBER, in sysevent_bind_subscriber_cmn()
2216 SH_BOUND(shp) = 1; in sysevent_bind_subscriber_cmn()
2217 SH_TYPE(shp) = SUBSCRIBER; in sysevent_bind_subscriber_cmn()
2218 SH_PRIV_DATA(shp) = (void *)sub_info; in sysevent_bind_subscriber_cmn()
2224 shp, THR_BOUND, &sub_info->sp_handler_tid) == 0; in sysevent_bind_subscriber_cmn()
2243 shp, xsa->xs_thrcreate_cookie) == 1; in sysevent_bind_subscriber_cmn()
2251 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_subscriber_cmn()
2257 (void) door_revoke(SH_DOOR_DESC(shp)); in sysevent_bind_subscriber_cmn()
2258 (void) fdetach(SH_DOOR_NAME(shp)); in sysevent_bind_subscriber_cmn()
2263 if (SH_ID(shp)) { in sysevent_bind_subscriber_cmn()
2264 (void) update_kernel_registration(shp, SUBSCRIBER, in sysevent_bind_subscriber_cmn()
2266 SH_ID(shp) = 0; in sysevent_bind_subscriber_cmn()
2268 if (SH_BOUND(shp)) { in sysevent_bind_subscriber_cmn()
2271 free(SH_DOOR_NAME(shp)); in sysevent_bind_subscriber_cmn()
2272 SH_BOUND(shp) = 0; in sysevent_bind_subscriber_cmn()
2274 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_bind_subscriber_cmn()
2285 sysevent_bind_subscriber(sysevent_handle_t *shp, in sysevent_bind_subscriber() argument
2288 return (sysevent_bind_subscriber_cmn(shp, event_handler, NULL)); in sysevent_bind_subscriber()
2296 sysevent_bind_xsubscriber(sysevent_handle_t *shp, in sysevent_bind_xsubscriber() argument
2299 return (sysevent_bind_subscriber_cmn(shp, event_handler, subattr)); in sysevent_bind_xsubscriber()
2307 sysevent_register_event(sysevent_handle_t *shp, in sysevent_register_event() argument
2318 (void) mutex_lock(SH_LOCK(shp)); in sysevent_register_event()
2320 event_subclass_list[0] == NULL || SH_BOUND(shp) != 1 || in sysevent_register_event()
2322 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_register_event()
2328 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_register_event()
2334 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_register_event()
2339 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_register_event()
2345 if (update_kernel_registration(shp, SUBSCRIBER, in sysevent_register_event()
2346 SE_REGISTER, &SH_ID(shp), datalen, (uchar_t *)nvlbuf) in sysevent_register_event()
2350 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_register_event()
2356 (subscriber_priv_t *)SH_PRIV_DATA(shp), SE_REGISTER, in sysevent_register_event()
2357 SH_ID(shp), datalen, (uchar_t *)nvlbuf) != 0) { in sysevent_register_event()
2360 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_register_event()
2367 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_register_event()
2377 sysevent_unregister_event(sysevent_handle_t *shp, const char *class) in sysevent_unregister_event() argument
2381 (void) mutex_lock(SH_LOCK(shp)); in sysevent_unregister_event()
2383 if (!SH_BOUND(shp)) { in sysevent_unregister_event()
2384 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_unregister_event()
2390 (void) update_kernel_registration(shp, SUBSCRIBER, in sysevent_unregister_event()
2391 SE_UNREGISTER, &SH_ID(shp), class_sz, (uchar_t *)class); in sysevent_unregister_event()
2394 (subscriber_priv_t *)SH_PRIV_DATA(shp), SE_UNREGISTER, in sysevent_unregister_event()
2395 SH_ID(shp), class_sz, (uchar_t *)class); in sysevent_unregister_event()
2397 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_unregister_event()
2401 cleanup_id(sysevent_handle_t *shp, uint32_t id, int type) in cleanup_id() argument
2403 dprint("cleanup_id: Cleaning up %s/%d\n", SH_CHANNEL_NAME(shp), id); in cleanup_id()
2406 if (update_kernel_registration(shp, type, SE_CLEANUP, &id, in cleanup_id()
2409 "up %s/%d\n", SH_CHANNEL_NAME(shp), id); in cleanup_id()
2421 sysevent_cleanup_subscribers(sysevent_handle_t *shp) in sysevent_cleanup_subscribers() argument
2427 if (!SH_BOUND(shp)) { in sysevent_cleanup_subscribers()
2433 sub = SH_SUBSCRIBER(shp, i); in sysevent_cleanup_subscribers()
2450 if (cleanup_id(shp, i, SUBSCRIBER) != 0) in sysevent_cleanup_subscribers()
2453 cache_remove_class(shp, EC_ALL, i); in sysevent_cleanup_subscribers()
2457 SH_SUBSCRIBER(shp, i) = NULL; in sysevent_cleanup_subscribers()
2467 sysevent_cleanup_publishers(sysevent_handle_t *shp) in sysevent_cleanup_publishers() argument
2469 (void) cleanup_id(shp, 1, PUBLISHER); in sysevent_cleanup_publishers()
2476 sysevent_unbind_subscriber(sysevent_handle_t *shp) in sysevent_unbind_subscriber() argument
2480 if (shp == NULL) in sysevent_unbind_subscriber()
2483 (void) mutex_lock(SH_LOCK(shp)); in sysevent_unbind_subscriber()
2484 if (SH_BOUND(shp) == 0) { in sysevent_unbind_subscriber()
2485 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_unbind_subscriber()
2490 (void) update_kernel_registration(shp, SUBSCRIBER, in sysevent_unbind_subscriber()
2491 SE_UNBIND_REGISTRATION, &SH_ID(shp), 0, NULL); in sysevent_unbind_subscriber()
2494 sub_info = (subscriber_priv_t *)SH_PRIV_DATA(shp); in sysevent_unbind_subscriber()
2496 SH_ID(shp), 0, NULL); in sysevent_unbind_subscriber()
2499 (void) door_revoke(SH_DOOR_DESC(shp)); in sysevent_unbind_subscriber()
2500 (void) fdetach(SH_DOOR_NAME(shp)); in sysevent_unbind_subscriber()
2507 SH_BOUND(shp) = 0; in sysevent_unbind_subscriber()
2518 free(SH_DOOR_NAME(shp)); in sysevent_unbind_subscriber()
2519 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_unbind_subscriber()
2526 sysevent_unbind_publisher(sysevent_handle_t *shp) in sysevent_unbind_publisher() argument
2528 if (shp == NULL) in sysevent_unbind_publisher()
2531 (void) mutex_lock(SH_LOCK(shp)); in sysevent_unbind_publisher()
2532 if (SH_BOUND(shp) == 0) { in sysevent_unbind_publisher()
2533 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_unbind_publisher()
2538 (void) door_revoke(SH_DOOR_DESC(shp)); in sysevent_unbind_publisher()
2539 (void) fdetach(SH_DOOR_NAME(shp)); in sysevent_unbind_publisher()
2542 (void) update_kernel_registration(shp, PUBLISHER, in sysevent_unbind_publisher()
2543 SE_UNBIND_REGISTRATION, &SH_ID(shp), 0, NULL); in sysevent_unbind_publisher()
2544 SH_BOUND(shp) = 0; in sysevent_unbind_publisher()
2547 free_cached_registration(shp); in sysevent_unbind_publisher()
2548 dealloc_subscribers(shp); in sysevent_unbind_publisher()
2550 free(SH_PRIV_DATA(shp)); in sysevent_unbind_publisher()
2551 free(SH_DOOR_NAME(shp)); in sysevent_unbind_publisher()
2552 SH_ID(shp) = 0; in sysevent_unbind_publisher()
2553 (void) mutex_unlock(SH_LOCK(shp)); in sysevent_unbind_publisher()
2564 sysevent_handle_t *shp; in sysevent_bind_handle_cmn() local
2576 if ((shp = sysevent_open_channel(SYSEVENTD_CHAN)) == NULL) { in sysevent_bind_handle_cmn()
2580 if (sysevent_bind_xsubscriber(shp, event_handler, subattr) != 0) { in sysevent_bind_handle_cmn()
2592 SH_CHANNEL_PATH(shp), REG_DOOR) >= MAXPATHLEN) { in sysevent_bind_handle_cmn()
2593 sysevent_close_channel(shp); in sysevent_bind_handle_cmn()
2605 if (sysevent_bind_xsubscriber(shp, event_handler, in sysevent_bind_handle_cmn()
2607 sysevent_close_channel(shp); in sysevent_bind_handle_cmn()
2611 sysevent_close_channel(shp); in sysevent_bind_handle_cmn()
2616 return (shp); in sysevent_bind_handle_cmn()
2644 sysevent_unbind_handle(sysevent_handle_t *shp) in sysevent_unbind_handle() argument
2646 sysevent_unbind_subscriber(shp); in sysevent_unbind_handle()
2647 sysevent_close_channel(shp); in sysevent_unbind_handle()
2655 sysevent_subscribe_event(sysevent_handle_t *shp, const char *event_class, in sysevent_subscribe_event() argument
2658 return (sysevent_register_event(shp, event_class, in sysevent_subscribe_event()
2663 sysevent_unsubscribe_event(sysevent_handle_t *shp, const char *event_class) in sysevent_unsubscribe_event() argument
2665 sysevent_unregister_event(shp, event_class); in sysevent_unsubscribe_event()