18 #include "trp_client.hpp"
19 #include "TransporterFacade.hpp"
21 trp_client::trp_client()
22 : m_blockNo(~Uint32(0)), m_facade(0)
24 m_poll.m_waiting =
false;
25 m_poll.m_locked =
false;
26 m_poll.m_poll_owner =
false;
29 m_poll.m_condition = NdbCondition_Create();
38 assert(m_poll.m_locked == 0);
39 assert(m_poll.m_poll_owner ==
false);
40 assert(m_poll.m_next == 0);
41 assert(m_poll.m_prev == 0);
44 NdbCondition_Destroy(m_poll.m_condition);
51 assert(m_facade == 0);
58 m_blockNo = refToBlock(res);
69 trp_client::getOwnNodeId()
const
71 return m_facade->theOwnId;
79 m_facade->close_clnt(
this);
82 m_blockNo = ~Uint32(0);
87 trp_client::start_poll()
89 m_facade->start_poll(
this);
93 trp_client::do_poll(Uint32
to)
95 m_facade->do_poll(
this, to);
99 trp_client::complete_poll()
101 m_facade->complete_poll(
this);
105 trp_client::do_forceSend(
int val)
109 m_facade->checkForceSend(m_blockNo);
113 m_facade->forceSend(m_blockNo);
120 return m_facade->m_poll_owner->raw_sendSignal(signal, nodeId);
123 #include "NdbImpl.hpp"
125 PollGuard::PollGuard(
NdbImpl& impl)
128 m_waiter= &impl.theWaiter;
129 m_clnt->start_poll();
147 int PollGuard::wait_n_unlock(
int wait_time, Uint32 nodeId, Uint32 state,
151 m_waiter->set_node(nodeId);
152 m_waiter->set_state(state);
153 ret_val= wait_for_input_in_loop(wait_time, forceSend);
158 int PollGuard::wait_scan(
int wait_time, Uint32 nodeId,
bool forceSend)
160 m_waiter->set_node(nodeId);
161 m_waiter->set_state(WAIT_SCAN);
162 return wait_for_input_in_loop(wait_time, forceSend);
165 int PollGuard::wait_for_input_in_loop(
int wait_time,
bool forceSend)
168 m_clnt->do_forceSend(forceSend ? 1 : 0);
170 NDB_TICKS curr_time = NdbTick_CurrentNanosecond();
172 NDB_TICKS max_time = curr_time + ((NDB_TICKS)wait_time * 1000000);
173 const int maxsleep = (wait_time == -1 || wait_time > 10) ? 10 : wait_time;
176 wait_for_input(maxsleep);
177 NDB_TICKS start_time_nanos = curr_time;
178 curr_time = NdbTick_CurrentNanosecond();
179 m_clnt->recordWaitTimeNanos(curr_time - start_time_nanos);
180 Uint32 state= m_waiter->get_state();
181 if (state == NO_WAIT)
185 else if (state == WAIT_NODE_FAILURE)
193 ndbout <<
"Waited WAITFOR_RESPONSE_TIMEOUT, continuing wait" << endl;
197 if (curr_time >= max_time)
200 ndbout <<
"Time-out state is " << m_waiter->get_state() << endl;
202 m_waiter->set_state(WST_WAIT_TIMEOUT);
208 ndbout <<
"ERR: receiveResponse - theImpl->theWaiter.m_state = ";
209 ndbout << m_waiter->get_state() << endl;
211 m_waiter->set_state(NO_WAIT);
215 void PollGuard::wait_for_input(
int wait_time)
217 m_clnt->do_poll(wait_time);
220 void PollGuard::unlock_and_signal()
222 m_clnt->complete_poll();