示例#1
0
/*   Wake up all attachments waiting to read events   */
int et_wakeup_all(et_sys_id id, et_stat_id stat_id)
{
  int i, status;
  et_att_id att;
  et_id *etid = (et_id *) id;
  et_station *ps;
  et_list    *pl, *pl_gc;

  if (stat_id < 0) {
    if (etid->debug >= ET_DEBUG_ERROR) {
      et_logmsg("ERROR", "et_wakeup_all, bad argument\n");
    }
    return ET_ERROR;
  }
  
  if (etid->locality != ET_LOCAL) {
    return etr_wakeup_all(id, stat_id);
  }
  
  /* 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_all, et id is closed\n");
      }
      return ET_ERROR_CLOSED;
  }
  
  ps = etid->grandcentral + stat_id;
  pl = &ps->list_in;
  pl_gc = &etid->grandcentral->list_in;

  if (stat_id >= etid->sys->config.nstations) {
      et_mem_unlock(etid);
      if (etid->debug >= ET_DEBUG_ERROR) {
          et_logmsg("ERROR", "et_wakeup_all, bad argument\n");
      }
      return ET_ERROR;
  }
  
  for (i=0; i < etid->sys->config.nattachments ; i++) {
    att = ps->data.att[i];
    if (att > -1) {
      if ((etid->sys->attach[att].blocked == ET_ATT_BLOCKED) ||
	      (etid->sys->attach[att].sleep == ET_ATT_SLEEP)) {
        etid->sys->attach[att].quit = ET_ATT_QUIT;
        if (etid->debug >= ET_DEBUG_INFO) {
          et_logmsg("INFO", "et_wakeup_all, waking up attachment %d\n", att);
        }
      } 
    }
  }
  /* attachment may be waiting on a "get", so wake own station in list */
  status = pthread_cond_broadcast(&pl->cread);
  if (status != 0) {
    err_abort(status, "Wakeup all 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 all readers");
  }
  
  et_mem_unlock(etid);
  return ET_OK;
}
示例#2
0
/*   Wake up all attachments waiting to read events   */
int et_wakeup_all(et_sys_id id, et_stat_id stat_id)
{
    return etr_wakeup_all(id, stat_id);
}