Beispiel #1
0
FD_EVENT TcpOp::event_op(const SocketNodePtr& node)
{
    FD_EVENT ret = FD_EVENT_NONE;


    if(node->_event & FD_EVENT_READ)
    {
        ret |= read(node);
        ret |= FD_EVENT_READ;
    }

    if(node->_event & FD_EVENT_WRITE)
    {
        FD_EVENT wt_ret =  write(node);
        if((wt_ret & FD_EVENT_WRITE) == false)
        {
            _epoll->epoll_in(node->_sfd);
        }

        ret |= wt_ret;
    }
    else
    {
        if(node->_wt_buff->data_size() > 0)
        {
            FD_EVENT wt_ret =  write(node);
            if((wt_ret & FD_EVENT_WRITE) == true)
            {
                _epoll->epoll_out(node->_sfd);
            }

            ret |= wt_ret;
        }
    }


    node->_event = FD_EVENT_NONE;
    node->_op_ret = FD_EVENT_NONE;

    if(ret & FD_EVENT_ERROR)
    {
        close_op(node->_sfd);
        return FD_EVENT_ERROR;
    }

    return ret;
}
int
Ndb_move_data::move_data(Ndb* ndb)
{
  int ret = 0;
  Op& op = m_op;
  Stat& stat = m_stat;
  stat.rows_moved = 0; // keep rows_total
  do
  {
    const NDB_TICKS now = NdbTick_getCurrentTicks(); 
    ndb_srand((unsigned)now.getUint64());
    reset_error();

    CHK2(m_source != 0 && m_target != 0,
        (Error::InvalidState, "source / target not defined"));

    op.ndb = ndb;
    CHK1(m_error.code == 0);
    CHK1(check_tables() == 0);
    CHK1(start_scan() == 0);
    while (1)
    {
      CHK1(move_batch() == 0);
      stat.rows_moved += op.rows_in_batch;
      stat.rows_total += op.rows_in_batch;
      stat.truncated += op.truncated_in_batch;

      require(op.end_of_scan == (op.rows_in_batch == 0));
      if (op.end_of_scan)
        break;
    }
    CHK1(ret == 0);
  }
  while (0);
  close_op(ndb, ret);
  return ret;
}