Пример #1
0
static void fc_dl_sl_do_combiner(fc_dl_skiplist_t *p){
	pub_record *i;
	int cpu, is_valid;
	__u64 dline;

	/* scansione publication list */
	for(i = dequeue_all_publication_record(p->p_list); i; i = i->next){
		/* evasione richiesta */
		switch(i->req){
			case PREEMPT:
				cpu = i->par.preempt_p.cpu;
				dline = i->par.preempt_p.dline;
				is_valid = i->par.preempt_p.is_valid;
				i->res.preempt_r.res = old_fc_dl_sl_preempt((void *)p, cpu, dline, is_valid);
				break;
		}

		SET_READY(i);
		/* FIXME: ??? */
		/* 
		 * attenzione: il publication record deve rimanere ACTIVE finchè non è stata
		 * letta la risposta. Poichè in questa simulazione le risposte vengono scartate
		 * lo poniamo inattivo qui.
		 */
		DEACTIVATE(i);
		__sync_synchronize();
	}

}
Пример #2
0
/*
 * EV connect callback
 *
 * EV_TIMER connect_timer
 */
  static void
_eredis_ev_connect_cb (struct ev_loop *loop, ev_timer *w, int revents)
{
  int i;
  eredis_t *e;

  (void) revents;
  (void) loop;

  e = (eredis_t*) w->data;

  if (IS_SHUTDOWN(e)) {
    if (e->hosts_connected) {
      for (i=0; i<e->hosts_nb; i++) {
        host_t *h = &e->hosts[i];
        if (H_IS_CONNECTED(h) && h->async_ctx)
          redisAsyncDisconnect( h->async_ctx );
      }
    }
    else {
      /* Connect timer */
      ev_timer_stop( e->loop, &e->connect_timer );
      /* Async send */
      ev_async_stop( e->loop, &e->send_async );
      /* Event break */
      ev_break( e->loop, EVBREAK_ALL );
    }
    return;
  }

  for (i=0; i<e->hosts_nb; i++) {
    host_t *h = &e->hosts[i];
    switch (H_CONN_STATE( h )) {
      case HOST_F_CONNECTED:
        break;

      case HOST_F_FAILED:
        if ((h->failures < HOST_FAILED_RETRY_AFTER)
            ||
            ( ! _host_connect( h, 0 ))) {
          h->failures %= HOST_FAILED_RETRY_AFTER;
          h->failures ++;
        }
        break;

      case HOST_F_DISCONNECTED:
        if (! _host_connect( h, 0 )) {
          if ((++ h->failures) > HOST_DISCONNECTED_RETRIES) {
            h->failures = 0;
            H_SET_FAILED( h );
          }
        }
        break;

      default:
        break;
    }
  }

  if (! IS_READY(e)) {
    /* Ready flag - need a connected host or a connection failure */
    int nb = 0;
    /* build ready flag */
    for (i=0; i<e->hosts_nb; i++) {
      host_t *h = &e->hosts[i];
      if (H_IS_INIT( h ))
        nb ++;
    }
    if (nb == e->hosts_nb) {
      SET_READY(e);
      e->send_async_pending = 1;
      ev_async_send( e->loop, &e->send_async );
    }
  }
}