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