Lines Matching refs:zevtchan

6195 do_callback(struct znotify *zevtchan, sysevent_t *ev)  in do_callback()  argument
6210 zevtchan->zn_failure_count++; in do_callback()
6225 ret = zevtchan->zn_callback(zonename, zid, newstate, in do_callback()
6226 oldstate, when, zevtchan->zn_private); in do_callback()
6229 zevtchan->zn_failure_count = 0; in do_callback()
6236 zevtchan->zn_failure_count = 0; in do_callback()
6244 struct znotify *zevtchan = p; in zn_cb() local
6247 (void) pthread_mutex_lock(&(zevtchan->zn_mutex)); in zn_cb()
6250 (void) pthread_mutex_unlock((&zevtchan->zn_mutex)); in zn_cb()
6254 if (zevtchan->zn_state == ZN_LOCKED) { in zn_cb()
6256 zevtchan->zn_failed = B_TRUE; in zn_cb()
6257 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex)); in zn_cb()
6261 if (zevtchan->zn_state == ZN_PING_INFLIGHT) { in zn_cb()
6263 zevtchan->zn_state = ZN_PING_RECEIVED; in zn_cb()
6264 (void) pthread_cond_signal(&(zevtchan->zn_cond)); in zn_cb()
6265 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex)); in zn_cb()
6268 zevtchan->zn_failed = B_TRUE; in zn_cb()
6269 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex)); in zn_cb()
6274 if (zevtchan->zn_state == ZN_UNLOCKED) { in zn_cb()
6276 error = do_callback(zevtchan, ev); in zn_cb()
6277 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex)); in zn_cb()
6289 if (zevtchan->zn_failure_count > ZONE_CB_RETRY_COUNT) { in zn_cb()
6292 (void) sleep(zevtchan->zn_failure_count); in zn_cb()
6297 if (zevtchan->zn_state == ZN_PING_RECEIVED) { in zn_cb()
6298 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex)); in zn_cb()
6309 struct znotify *zevtchan = h; in zonecfg_notify_critical_enter() local
6311 (void) pthread_mutex_lock(&(zevtchan->zn_bigmutex)); in zonecfg_notify_critical_enter()
6312 zevtchan->zn_state = ZN_LOCKED; in zonecfg_notify_critical_enter()
6319 struct znotify *zevtchan = h; in zonecfg_notify_critical_exit() local
6321 if (zevtchan->zn_state == ZN_UNLOCKED) in zonecfg_notify_critical_exit()
6324 (void) pthread_mutex_lock(&(zevtchan->zn_mutex)); in zonecfg_notify_critical_exit()
6325 zevtchan->zn_state = ZN_PING_INFLIGHT; in zonecfg_notify_critical_exit()
6327 (void) sysevent_evc_publish(zevtchan->zn_eventchan, in zonecfg_notify_critical_exit()
6330 zevtchan->zn_subscriber_id, NULL, EVCH_SLEEP); in zonecfg_notify_critical_exit()
6332 while (zevtchan->zn_state != ZN_PING_RECEIVED) { in zonecfg_notify_critical_exit()
6333 (void) pthread_cond_wait(&(zevtchan->zn_cond), in zonecfg_notify_critical_exit()
6334 &(zevtchan->zn_mutex)); in zonecfg_notify_critical_exit()
6337 if (zevtchan->zn_failed == B_TRUE) { in zonecfg_notify_critical_exit()
6338 zevtchan->zn_state = ZN_LOCKED; in zonecfg_notify_critical_exit()
6339 zevtchan->zn_failed = B_FALSE; in zonecfg_notify_critical_exit()
6340 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex)); in zonecfg_notify_critical_exit()
6344 zevtchan->zn_state = ZN_UNLOCKED; in zonecfg_notify_critical_exit()
6345 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex)); in zonecfg_notify_critical_exit()
6346 (void) pthread_mutex_unlock(&(zevtchan->zn_bigmutex)); in zonecfg_notify_critical_exit()
6353 struct znotify *zevtchan = h; in zonecfg_notify_critical_abort() local
6355 zevtchan->zn_state = ZN_UNLOCKED; in zonecfg_notify_critical_abort()
6356 zevtchan->zn_failed = B_FALSE; in zonecfg_notify_critical_abort()
6361 (void) pthread_mutex_unlock(&(zevtchan->zn_bigmutex)); in zonecfg_notify_critical_abort()
6369 struct znotify *zevtchan; in zonecfg_notify_bind() local
6373 zevtchan = malloc(sizeof (struct znotify)); in zonecfg_notify_bind()
6375 if (zevtchan == NULL) in zonecfg_notify_bind()
6378 zevtchan->zn_private = p; in zonecfg_notify_bind()
6379 zevtchan->zn_callback = func; in zonecfg_notify_bind()
6380 zevtchan->zn_state = ZN_UNLOCKED; in zonecfg_notify_bind()
6381 zevtchan->zn_failed = B_FALSE; in zonecfg_notify_bind()
6383 if (pthread_mutex_init(&(zevtchan->zn_mutex), NULL)) in zonecfg_notify_bind()
6385 if (pthread_cond_init(&(zevtchan->zn_cond), NULL)) { in zonecfg_notify_bind()
6386 (void) pthread_mutex_destroy(&(zevtchan->zn_mutex)); in zonecfg_notify_bind()
6389 if (pthread_mutex_init(&(zevtchan->zn_bigmutex), NULL)) { in zonecfg_notify_bind()
6390 (void) pthread_mutex_destroy(&(zevtchan->zn_mutex)); in zonecfg_notify_bind()
6391 (void) pthread_cond_destroy(&(zevtchan->zn_cond)); in zonecfg_notify_bind()
6395 if (sysevent_evc_bind(ZONE_EVENT_CHANNEL, &(zevtchan->zn_eventchan), in zonecfg_notify_bind()
6407 (void) sprintf(zevtchan->zn_subscriber_id, "zone_%li_%i", in zonecfg_notify_bind()
6410 r = sysevent_evc_subscribe(zevtchan->zn_eventchan, in zonecfg_notify_bind()
6411 zevtchan->zn_subscriber_id, ZONE_EVENT_STATUS_CLASS, zn_cb, in zonecfg_notify_bind()
6412 zevtchan, 0); in zonecfg_notify_bind()
6418 return (zevtchan); in zonecfg_notify_bind()
6420 (void) sysevent_evc_unbind(zevtchan->zn_eventchan); in zonecfg_notify_bind()
6422 (void) pthread_mutex_destroy(&zevtchan->zn_mutex); in zonecfg_notify_bind()
6423 (void) pthread_cond_destroy(&zevtchan->zn_cond); in zonecfg_notify_bind()
6424 (void) pthread_mutex_destroy(&(zevtchan->zn_bigmutex)); in zonecfg_notify_bind()
6426 free(zevtchan); in zonecfg_notify_bind()