/* Wake up a specific attachment waiting to read events.*/ int et_wakeup_attachment(et_sys_id id, et_att_id att) { int status; et_id *etid = (et_id *) id; et_stat_id stat_id; et_station *ps; et_list *pl, *pl_gc; if (att < 0) { if (etid->debug >= ET_DEBUG_ERROR) { et_logmsg("ERROR", "et_wakeup_attachment, bad argument\n"); } return ET_ERROR; } if (etid->locality != ET_LOCAL) { return etr_wakeup_attachment(id, att); } /* Protection from (local) et_close() unmapping shared memory */ et_memRead_lock(etid); /* Has caller already called et_close()? */ if (etid->closed) { et_mem_unlock(etid); if (etid->debug >= ET_DEBUG_ERROR) { et_logmsg("ERROR", "et_wakeup_attachment, et id is closed\n"); } return ET_ERROR_CLOSED; } stat_id = etid->sys->attach[att].stat; ps = etid->grandcentral + stat_id; pl = &ps->list_in; pl_gc = &etid->grandcentral->list_in; if (att >= etid->sys->config.nattachments) { et_mem_unlock(etid); if (etid->debug >= ET_DEBUG_ERROR) { et_logmsg("ERROR", "et_wakeup_attachment, bad argument\n"); } return ET_ERROR; } /* Only tell things to wake up if they are sleeping, otherwise * after the NEXT read, it will quit as if being woken up! */ if ((etid->sys->attach[att].blocked == ET_ATT_UNBLOCKED) && (etid->sys->attach[att].sleep == ET_ATT_NOSLEEP)) { et_mem_unlock(etid); if (etid->debug >= ET_DEBUG_WARN) { et_logmsg("WARN", "et_wakeup_attachment, attachment is NOT blocked so not sending wakeup signal\n"); } return ET_OK; } if (etid->debug >= ET_DEBUG_INFO) { et_logmsg("INFO", "et_wakeup_attachment, waking up attachment %d\n", att); } /* attachment may be waiting on a "get", so wake own station in list */ etid->sys->attach[att].quit = ET_ATT_QUIT; status = pthread_cond_broadcast(&pl->cread); if (status != 0) { err_abort(status, "Wakeup readers"); } /* attachment may be waiting on a "new", so wake GrandCentral's in list */ status = pthread_cond_broadcast(&pl_gc->cread); if (status != 0) { err_abort(status, "Wakeup readers"); } et_mem_unlock(etid); return ET_OK; }
int et_wakeup_attachment(et_sys_id id, et_att_id att) { return etr_wakeup_attachment(id, att); }