static int devi_notify(resmgr_context_t *ctp, io_notify_t *msg, RESMGR_OCB_T *ocb) { devi_attr_t *attr = ocb->ocb.attr; event_bus_line_t *line = attr->line; int trig = 0, n; int sts; /* we don't support output or out of band notification */ if (msg->i.flags & (_NOTIFY_COND_OBAND | _NOTIFY_COND_OUTPUT)) return (ENOSYS); pthread_mutex_lock(&line->mutex); /* if queue non-empty, trigger */ if (ocb->read_ptr != line->head) trig = _NOTIFY_COND_INPUT; pthread_mutex_unlock(&line->mutex); sts = iofunc_notify(ctp, msg, attr->notify, trig, NULL, &n); if (sts == EBUSY) return (EBUSY); if (n) attr->flags |= DEVI_NOTIFICATION_ARMED; return (_RESMGR_NPARTS(1)); }
int io_notify(resmgr_context_t *ctp, io_notify_t *msg, struct ocb *ocb) { MQDEV *dev = ocb->ocb.attr; int status, n, trig, notifycnts[3] = {1, 1, 1}; // Calculate which sources are statisfied (immediate trigger). trig = 0; if(dev->mq_attr.mq_curmsgs) { trig |= _NOTIFY_COND_INPUT; } if(dev->mq_attr.mq_maxmsg - dev->mq_attr.mq_curmsgs > 0) { trig |= _NOTIFY_COND_OUTPUT; } // // Process the notify request. // "n" will be set to 1 if a notify entry is armed. // status = iofunc_notify(ctp, msg, &dev->notify[0], trig, notifycnts, &n); /* Tie the ocb which attached the nofication. On close we'll need this to determine if the close() should remove the notification PR 1207 */ if (n) ocb->notify_attached++; else ocb->notify_attached--; // // Since the messages can't change under our feet we don't need to // recheck them like we did in chario which has async input from // an interrupt handler. // return status; }