Lines Matching defs:zevtchan
6033 do_callback(struct znotify *zevtchan, sysevent_t *ev)
6048 zevtchan->zn_failure_count++;
6063 ret = zevtchan->zn_callback(zonename, zid, newstate,
6064 oldstate, when, zevtchan->zn_private);
6067 zevtchan->zn_failure_count = 0;
6074 zevtchan->zn_failure_count = 0;
6082 struct znotify *zevtchan = p;
6085 (void) pthread_mutex_lock(&(zevtchan->zn_mutex));
6088 (void) pthread_mutex_unlock((&zevtchan->zn_mutex));
6092 if (zevtchan->zn_state == ZN_LOCKED) {
6094 zevtchan->zn_failed = B_TRUE;
6095 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6099 if (zevtchan->zn_state == ZN_PING_INFLIGHT) {
6101 zevtchan->zn_state = ZN_PING_RECEIVED;
6102 (void) pthread_cond_signal(&(zevtchan->zn_cond));
6103 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6106 zevtchan->zn_failed = B_TRUE;
6107 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6112 if (zevtchan->zn_state == ZN_UNLOCKED) {
6114 error = do_callback(zevtchan, ev);
6115 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6127 if (zevtchan->zn_failure_count > ZONE_CB_RETRY_COUNT) {
6130 (void) sleep(zevtchan->zn_failure_count);
6135 if (zevtchan->zn_state == ZN_PING_RECEIVED) {
6136 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6147 struct znotify *zevtchan = h;
6149 (void) pthread_mutex_lock(&(zevtchan->zn_bigmutex));
6150 zevtchan->zn_state = ZN_LOCKED;
6157 struct znotify *zevtchan = h;
6159 if (zevtchan->zn_state == ZN_UNLOCKED)
6162 (void) pthread_mutex_lock(&(zevtchan->zn_mutex));
6163 zevtchan->zn_state = ZN_PING_INFLIGHT;
6165 (void) sysevent_evc_publish(zevtchan->zn_eventchan,
6168 zevtchan->zn_subscriber_id, NULL, EVCH_SLEEP);
6170 while (zevtchan->zn_state != ZN_PING_RECEIVED) {
6171 (void) pthread_cond_wait(&(zevtchan->zn_cond),
6172 &(zevtchan->zn_mutex));
6175 if (zevtchan->zn_failed == B_TRUE) {
6176 zevtchan->zn_state = ZN_LOCKED;
6177 zevtchan->zn_failed = B_FALSE;
6178 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6182 zevtchan->zn_state = ZN_UNLOCKED;
6183 (void) pthread_mutex_unlock(&(zevtchan->zn_mutex));
6184 (void) pthread_mutex_unlock(&(zevtchan->zn_bigmutex));
6191 struct znotify *zevtchan = h;
6193 zevtchan->zn_state = ZN_UNLOCKED;
6194 zevtchan->zn_failed = B_FALSE;
6199 (void) pthread_mutex_unlock(&(zevtchan->zn_bigmutex));
6207 struct znotify *zevtchan;
6211 zevtchan = malloc(sizeof (struct znotify));
6213 if (zevtchan == NULL)
6216 zevtchan->zn_private = p;
6217 zevtchan->zn_callback = func;
6218 zevtchan->zn_state = ZN_UNLOCKED;
6219 zevtchan->zn_failed = B_FALSE;
6221 if (pthread_mutex_init(&(zevtchan->zn_mutex), NULL))
6223 if (pthread_cond_init(&(zevtchan->zn_cond), NULL)) {
6224 (void) pthread_mutex_destroy(&(zevtchan->zn_mutex));
6227 if (pthread_mutex_init(&(zevtchan->zn_bigmutex), NULL)) {
6228 (void) pthread_mutex_destroy(&(zevtchan->zn_mutex));
6229 (void) pthread_cond_destroy(&(zevtchan->zn_cond));
6233 if (sysevent_evc_bind(ZONE_EVENT_CHANNEL, &(zevtchan->zn_eventchan),
6245 (void) sprintf(zevtchan->zn_subscriber_id, "zone_%li_%i",
6248 r = sysevent_evc_subscribe(zevtchan->zn_eventchan,
6249 zevtchan->zn_subscriber_id, ZONE_EVENT_STATUS_CLASS, zn_cb,
6250 zevtchan, 0);
6256 return (zevtchan);
6258 (void) sysevent_evc_unbind(zevtchan->zn_eventchan);
6260 (void) pthread_mutex_destroy(&zevtchan->zn_mutex);
6261 (void) pthread_cond_destroy(&zevtchan->zn_cond);
6262 (void) pthread_mutex_destroy(&(zevtchan->zn_bigmutex));
6264 free(zevtchan);