Ejemplo n.º 1
0
int statsx_replay_logevent (struct lev_generic *E, int size) {
  int type, s;
  static int type_ok = -1;

  if (size < 4) {
    return -2;
  }

  type = *((int *)E);
  s = get_logrec_size (type, E, size);

  if (s > size || s == -2) {
    return -2;
  }

  if (s < 0) {
    fprintf (stderr, "error %d reading binlog at position %lld, write position %lld, type %08x (prev type %08x)\n", s, log_cur_pos(), wr_bytes + targ_orig_size, type, type_ok);
    return s;
  }

  if (!targ_existed && type != LEV_START && jump_log_pos == 0) {
    fprintf (stderr, "error: first record must be a LEV_START\n");
    return -1;
  }

  rd_bytes += s;
  rd_rec++;

  type_ok = type;

  s = ((s + 3) & -4);

  if (want_write (type, E)) {
    if (LogTs.timestamp) {
      memcpy (write_alloc (8), &LogTs, 8);
      wr_bytes += 8;
      wr_rec++;
      LogTs.timestamp = 0;
    }
    struct lev_generic *N = write_alloc (s);
    memcpy (N, E, s);
    if (type == LEV_START) {
      N->c = copy_mod;
      N->d = copy_rem;
      N->e = copy_rem+1;
    }
    wr_bytes += s;
    wr_rec++;
  }

  return s;
}
Ejemplo n.º 2
0
void SopoMygga::timerEvent(QTimerEvent *event)
{
    int r;

    r=loop_misc();
    if (r!=MOSQ_ERR_SUCCESS) {
        qWarning() << "Misc fail " << r;
    }

    m_notifier_write->setEnabled(true);

    if (want_write()==true) {
        qDebug("NWWW");
        loopWrite();
    }
}
Ejemplo n.º 3
0
void SopoMygga::loopWrite() {
    int r;

    m_notifier_write->setEnabled(false);

    r=loop_misc();
    if (r!=MOSQ_ERR_SUCCESS) {
        qWarning() << "Misc fail " << r;
    }

    if (want_write()==false) {
        return;
    }

    qDebug("LW");
    r=loop_write();
    if (r!=MOSQ_ERR_SUCCESS) {
        qWarning() << "Write fail " << r;
    }

}