Lines Matching defs:zevtchan

6193 do_callback(struct znotify *zevtchan, sysevent_t *ev)
6208 zevtchan->zn_failure_count++;
6223 ret = zevtchan->zn_callback(zonename, zid, newstate,
6224 oldstate, when, zevtchan->zn_private);
6227 zevtchan->zn_failure_count = 0;
6234 zevtchan->zn_failure_count = 0;
6242 struct znotify *zevtchan = p;
6245 (void) pthread_mutex_lock(&(zevtchan->zn_mutex));
6248 (void) pthread_mutex_unlock((&zevtchan->zn_mutex));
6252 if (zevtchan->zn_state == ZN_LOCKED) {
6254 zevtchan->zn_failed = B_TRUE;
6255 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6259 if (zevtchan->zn_state == ZN_PING_INFLIGHT) {
6261 zevtchan->zn_state = ZN_PING_RECEIVED;
6262 (void) pthread_cond_signal(&(zevtchan->zn_cond));
6263 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6266 zevtchan->zn_failed = B_TRUE;
6267 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6272 if (zevtchan->zn_state == ZN_UNLOCKED) {
6274 error = do_callback(zevtchan, ev);
6275 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6287 if (zevtchan->zn_failure_count > ZONE_CB_RETRY_COUNT) {
6290 (void) sleep(zevtchan->zn_failure_count);
6295 if (zevtchan->zn_state == ZN_PING_RECEIVED) {
6296 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6307 struct znotify *zevtchan = h;
6309 (void) pthread_mutex_lock(&(zevtchan->zn_bigmutex));
6310 zevtchan->zn_state = ZN_LOCKED;
6317 struct znotify *zevtchan = h;
6319 if (zevtchan->zn_state == ZN_UNLOCKED)
6322 (void) pthread_mutex_lock(&(zevtchan->zn_mutex));
6323 zevtchan->zn_state = ZN_PING_INFLIGHT;
6325 (void) sysevent_evc_publish(zevtchan->zn_eventchan,
6328 zevtchan->zn_subscriber_id, NULL, EVCH_SLEEP);
6330 while (zevtchan->zn_state != ZN_PING_RECEIVED) {
6331 (void) pthread_cond_wait(&(zevtchan->zn_cond),
6332 &(zevtchan->zn_mutex));
6335 if (zevtchan->zn_failed == B_TRUE) {
6336 zevtchan->zn_state = ZN_LOCKED;
6337 zevtchan->zn_failed = B_FALSE;
6338 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6342 zevtchan->zn_state = ZN_UNLOCKED;
6343 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6344 (void) pthread_mutex_unlock(&(zevtchan->zn_bigmutex));
6351 struct znotify *zevtchan = h;
6353 zevtchan->zn_state = ZN_UNLOCKED;
6354 zevtchan->zn_failed = B_FALSE;
6359 (void) pthread_mutex_unlock(&(zevtchan->zn_bigmutex));
6367 struct znotify *zevtchan;
6371 zevtchan = malloc(sizeof (struct znotify));
6373 if (zevtchan == NULL)
6376 zevtchan->zn_private = p;
6377 zevtchan->zn_callback = func;
6378 zevtchan->zn_state = ZN_UNLOCKED;
6379 zevtchan->zn_failed = B_FALSE;
6381 if (pthread_mutex_init(&(zevtchan->zn_mutex), NULL))
6383 if (pthread_cond_init(&(zevtchan->zn_cond), NULL)) {
6384 (void) pthread_mutex_destroy(&(zevtchan->zn_mutex));
6387 if (pthread_mutex_init(&(zevtchan->zn_bigmutex), NULL)) {
6388 (void) pthread_mutex_destroy(&(zevtchan->zn_mutex));
6389 (void) pthread_cond_destroy(&(zevtchan->zn_cond));
6393 if (sysevent_evc_bind(ZONE_EVENT_CHANNEL, &(zevtchan->zn_eventchan),
6405 (void) sprintf(zevtchan->zn_subscriber_id, "zone_%li_%i",
6408 r = sysevent_evc_subscribe(zevtchan->zn_eventchan,
6409 zevtchan->zn_subscriber_id, ZONE_EVENT_STATUS_CLASS, zn_cb,
6410 zevtchan, 0);
6416 return (zevtchan);
6418 (void) sysevent_evc_unbind(zevtchan->zn_eventchan);
6420 (void) pthread_mutex_destroy(&zevtchan->zn_mutex);
6421 (void) pthread_cond_destroy(&zevtchan->zn_cond);
6422 (void) pthread_mutex_destroy(&(zevtchan->zn_bigmutex));
6424 free(zevtchan);