Ejemplo n.º 1
0
tree
edit_env_rep::rewrite_inactive_arg (
  tree t, tree var, int i, bool block, bool flush)
{
  tree r= subvar (var, i);
  if ((inactive_mode == INACTIVE_INLINE_RECURSE) ||
      (inactive_mode == INACTIVE_BLOCK_RECURSE))
    {
      if (N (recover_env) > 0) {
	int j;
	tree recover= copy (recover_env), old_recover= recover_env;
	for (j=0; j<N(recover); j+=2) {
	  string var= recover[j]->label;
	  recover[j+1]= read (var);
	  write_update (var, recover_env[j+1]);
	}
	recover_env= tuple ();
	r= rewrite_inactive (t[i], r, block, flush);
	recover_env= old_recover;
	for (j=0; j<N(recover); j+=2)
	  write_update (recover[j]->label, recover[j+1]);
      }
      else r= rewrite_inactive (t[i], r, block, flush);
    }
  return highlight (r, t[i], drd->get_type_child (t, i));
}
Ejemplo n.º 2
0
/* Unix only provides a single ALRM signal, so we use the same handler for
 * frequent updates (every 5 seconds) and differential updates (every 30
 * seconds). We trigger an ALRM every 5 seconds and only write differential
 * updates every 6th ALRM. */
static void handle_signals(int sig) {
  if (sig == SIGINT || sig == SIGTERM) {
    write_update();
#ifdef ENABLE_FREQUENT_UPDATES
    write_frequent_update();
#endif
    exit(0);
  } else if (sig == SIGALRM) {
    alarm_count += 1;
    if (alarm_count % ALARMS_PER_UPDATE == 0) {
#ifndef DISABLE_FLOW_THRESHOLDING
      write_flow_log();
#endif
      write_update();
    }
#ifdef ENABLE_FREQUENT_UPDATES
    write_frequent_update();
#endif
    if (alarm_count % ALARMS_PER_UPDATE == 0
        && upload_failures_check(&upload_failures) > 0) {
      exit(0);
    }
    set_next_alarm();
  }
}
Ejemplo n.º 3
0
tree
edit_env_rep::rewrite_inactive_style_with (
  tree t, tree var, bool block, bool flush, bool once)
{
  int i, n= N(t);
  tree recover= tuple ();
  for (i=0; i<n-1; i+=2)
    if (is_atomic (t[i])) {
      recover << t[i] << read (t[i]->label);
      write_update (t[i]->label, t[i+1]);
    }
  if (once) recover_env= recover;
  tree r= rewrite_inactive (t[n-1], subvar (var, n-1), block, flush);
  for (i=0; i<N(recover); i+=2)
    write_update (recover[i]->label, recover[i+1]);
  if (once) recover_env= tuple ();
  return tree (MARK, var, r);
}
Ejemplo n.º 4
0
void
edit_env_rep::patch_env (hashmap<string,tree> patch) {
  if (patch->size == 0) return;
  int i=0, n=patch->n;
  for (; i<n; i++) {
    list<hashentry<string,tree> > l=patch->a[i];
    for (; !is_nil(l); l=l->next)
      write_update (l->item.key, l->item.im);
  }
}
Ejemplo n.º 5
0
static void* updater(void* arg) {
  while (1) {
    sleep(UPDATE_PERIOD_SECONDS);
    if (pthread_mutex_lock(&update_lock)) {
      perror("Error acquiring mutex for update");
      exit(1);
    }
    write_update();
    if (pthread_mutex_unlock(&update_lock)) {
      perror("Error unlocking update mutex");
      exit(1);
    }
  }
}
Ejemplo n.º 6
0
static void* handle_signals(void* arg) {
  sigset_t* signal_set = (sigset_t*)arg;
  int signal_handled;
  while (1) {
    if (sigwait(signal_set, &signal_handled)) {
      perror("Error handling signal");
      continue;
    }
    if (pthread_mutex_lock(&update_lock)) {
      perror("Error acquiring mutex for update");
      exit(1);
    }
    write_update();
#ifdef ENABLE_FREQUENT_UPDATES
    write_frequent_update();
#endif
    exit(0);
  }
}
Ejemplo n.º 7
0
 void
 Vcd_instrumenter::step(ir::Time const& t) {
   LOG4CXX_TRACE(m_logger, "step to time " << t);
   write_update(m_os, t);
 }