Lines Matching defs:zevtchan

7291 do_callback(struct znotify *zevtchan, sysevent_t *ev)
7306 zevtchan->zn_failure_count++;
7321 ret = zevtchan->zn_callback(zonename, zid, newstate,
7322 oldstate, when, zevtchan->zn_private);
7325 zevtchan->zn_failure_count = 0;
7332 zevtchan->zn_failure_count = 0;
7340 struct znotify *zevtchan = p;
7343 (void) pthread_mutex_lock(&(zevtchan->zn_mutex));
7346 (void) pthread_mutex_unlock((&zevtchan->zn_mutex));
7350 if (zevtchan->zn_state == ZN_LOCKED) {
7352 zevtchan->zn_failed = B_TRUE;
7353 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
7357 if (zevtchan->zn_state == ZN_PING_INFLIGHT) {
7359 zevtchan->zn_state = ZN_PING_RECEIVED;
7360 (void) pthread_cond_signal(&(zevtchan->zn_cond));
7361 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
7364 zevtchan->zn_failed = B_TRUE;
7365 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
7370 if (zevtchan->zn_state == ZN_UNLOCKED) {
7372 error = do_callback(zevtchan, ev);
7373 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
7385 if (zevtchan->zn_failure_count > ZONE_CB_RETRY_COUNT) {
7388 (void) sleep(zevtchan->zn_failure_count);
7393 if (zevtchan->zn_state == ZN_PING_RECEIVED) {
7394 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
7404 struct znotify *zevtchan = h;
7406 (void) pthread_mutex_lock(&(zevtchan->zn_bigmutex));
7407 zevtchan->zn_state = ZN_LOCKED;
7414 struct znotify *zevtchan = h;
7416 if (zevtchan->zn_state == ZN_UNLOCKED)
7419 (void) pthread_mutex_lock(&(zevtchan->zn_mutex));
7420 zevtchan->zn_state = ZN_PING_INFLIGHT;
7422 (void) sysevent_evc_publish(zevtchan->zn_eventchan,
7425 zevtchan->zn_subscriber_id, NULL, EVCH_SLEEP);
7427 while (zevtchan->zn_state != ZN_PING_RECEIVED) {
7428 (void) pthread_cond_wait(&(zevtchan->zn_cond),
7429 &(zevtchan->zn_mutex));
7432 if (zevtchan->zn_failed == B_TRUE) {
7433 zevtchan->zn_state = ZN_LOCKED;
7434 zevtchan->zn_failed = B_FALSE;
7435 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
7439 zevtchan->zn_state = ZN_UNLOCKED;
7440 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
7441 (void) pthread_mutex_unlock(&(zevtchan->zn_bigmutex));
7448 struct znotify *zevtchan = h;
7450 zevtchan->zn_state = ZN_UNLOCKED;
7451 zevtchan->zn_failed = B_FALSE;
7456 (void) pthread_mutex_unlock(&(zevtchan->zn_bigmutex));
7464 struct znotify *zevtchan;
7468 zevtchan = malloc(sizeof (struct znotify));
7470 if (zevtchan == NULL)
7473 zevtchan->zn_private = p;
7474 zevtchan->zn_callback = func;
7475 zevtchan->zn_state = ZN_UNLOCKED;
7476 zevtchan->zn_failed = B_FALSE;
7478 if (pthread_mutex_init(&(zevtchan->zn_mutex), NULL))
7480 if (pthread_cond_init(&(zevtchan->zn_cond), NULL)) {
7481 (void) pthread_mutex_destroy(&(zevtchan->zn_mutex));
7484 if (pthread_mutex_init(&(zevtchan->zn_bigmutex), NULL)) {
7485 (void) pthread_mutex_destroy(&(zevtchan->zn_mutex));
7486 (void) pthread_cond_destroy(&(zevtchan->zn_cond));
7490 if (sysevent_evc_bind(ZONE_EVENT_CHANNEL, &(zevtchan->zn_eventchan),
7502 (void) sprintf(zevtchan->zn_subscriber_id, "zone_%li_%i",
7505 r = sysevent_evc_subscribe(zevtchan->zn_eventchan,
7506 zevtchan->zn_subscriber_id, ZONE_EVENT_STATUS_CLASS, zn_cb,
7507 zevtchan, 0);
7513 return (zevtchan);
7515 (void) sysevent_evc_unbind(zevtchan->zn_eventchan);
7517 (void) pthread_mutex_destroy(&zevtchan->zn_mutex);
7518 (void) pthread_cond_destroy(&zevtchan->zn_cond);
7519 (void) pthread_mutex_destroy(&(zevtchan->zn_bigmutex));
7521 free(zevtchan);