18 #include "SignalSender.hpp"
19 #include <kernel/GlobalSignalNumbers.h>
21 #include <SignalLoggerManager.hpp>
22 #include <signaldata/NFCompleteRep.hpp>
23 #include <signaldata/NodeFailRep.hpp>
24 #include <signaldata/TestOrd.hpp>
27 SimpleSignal::SimpleSignal(
bool dealloc)
28 : header((BlockReference)0)
30 memset(ptr, 0,
sizeof(ptr));
31 deallocSections = dealloc;
37 deallocSections =
true;
39 for (Uint32
i = 0;
i<NDB_ARRAY_SIZE(ptr);
i++)
42 if (src.ptr[
i].p != 0)
44 ptr[
i].p =
new Uint32[src.ptr[
i].sz];
45 ptr[
i].sz = src.ptr[
i].sz;
46 memcpy(ptr[
i].p, src.ptr[
i].p, 4 * src.ptr[
i].sz);
55 deallocSections =
true;
57 for (Uint32
i = 0;
i<NDB_ARRAY_SIZE(ptr);
i++)
60 if (src.ptr[
i].p != 0)
62 ptr[
i].p =
new Uint32[src.ptr[
i].sz];
63 ptr[
i].sz = src.ptr[
i].sz;
64 memcpy(ptr[
i].p, src.ptr[
i].p, 4 * src.ptr[
i].sz);
70 SimpleSignal::~SimpleSignal(){
74 for (Uint32
i = 0;
i<NDB_ARRAY_SIZE(ptr);
i++)
85 Uint8 trace, Uint16 recBlock, Uint16 gsn, Uint32 len)
87 header.set(trace, recBlock, gsn, len);
88 header.theSendersBlockRef = refToBlock(ss.getOwnRef());
92 SimpleSignal::print(FILE * out)
const {
93 fprintf(out,
"---- Signal ----------------\n");
96 for(Uint32
i = 0;
i<header.m_noOfSections;
i++){
97 Uint32 len = ptr[
i].sz;
98 fprintf(out,
" --- Section %d size=%d ---\n",
i, len);
99 Uint32 * signalData = ptr[
i].p;
102 " H\'%.8x H\'%.8x H\'%.8x H\'%.8x H\'%.8x H\'%.8x H\'%.8x\n",
103 signalData[0], signalData[1], signalData[2], signalData[3],
104 signalData[4], signalData[5], signalData[6]);
109 fprintf(out,
" H\'%.8x", signalData[0]);
110 for(Uint32
i = 1;
i<len;
i++)
111 fprintf(out,
" H\'%.8x", signalData[
i]);
120 Uint32 res = open(theFacade, blockNo);
122 m_blockNo = refToBlock(res);
127 theFacade = connection->m_impl.m_transporter_facade;
128 Uint32 res = open(theFacade, -1);
130 m_blockNo = refToBlock(res);
133 SignalSender::~SignalSender(){
140 for (i= m_jobBuffer.size()-1; i>= 0; i--)
141 delete m_jobBuffer[i];
142 for (i= m_usedBuffer.size()-1; i>= 0; i--)
143 delete m_usedBuffer[i];
146 int SignalSender::lock()
152 int SignalSender::unlock()
159 SignalSender::getOwnRef()
const {
160 return numberToRef(m_blockNo, theFacade->ownId());
166 Uint16 recBlock, Uint16 gsn,
169 sig.set(*
this, TestOrd::TraceAPI, recBlock, gsn, len);
172 for(Uint32 i = 0; i < MAX_NODES; i++)
174 if(mask.
get(i) && sendSignal(i, &sig) == SEND_OK)
182 SignalSender::sendSignal(Uint16 nodeId,
184 Uint16 recBlock, Uint16 gsn,
187 sig.set(*
this, TestOrd::TraceAPI, recBlock, gsn, len);
188 return sendSignal(nodeId, &sig);
192 SignalSender::sendFragmentedSignal(Uint16 nodeId,
194 Uint16 recBlock, Uint16 gsn,
197 sig.set(*
this, TestOrd::TraceAPI, recBlock, gsn, len);
199 int ret = raw_sendFragmentedSignal(&sig.header,
202 sig.header.m_noOfSections);
208 return SEND_DISCONNECTED;
212 SignalSender::sendSignal(Uint16 nodeId,
const SimpleSignal * s)
217 s->header.m_noOfSections);
223 return SEND_DISCONNECTED;
228 SignalSender::waitFor(Uint32 timeOutMillis, T & t)
232 if (m_usedBuffer.push_back(s))
236 assert(s->header.theLength > 0);
241 for (
unsigned i= 0; i < m_usedBuffer.size(); i++)
242 delete m_usedBuffer[i];
243 m_usedBuffer.clear();
245 NDB_TICKS now = NdbTick_CurrentMillisecond();
246 NDB_TICKS stop = now + timeOutMillis;
247 Uint32 wait = (timeOutMillis == 0 ? 10 : timeOutMillis);
253 if (m_usedBuffer.push_back(s))
257 assert(s->header.theLength > 0);
261 now = NdbTick_CurrentMillisecond();
262 wait = (Uint32)(timeOutMillis == 0 ? 10 : stop - now);
263 }
while(stop > now || timeOutMillis == 0);
272 if(m_jobBuffer.size() > 0){
274 m_jobBuffer.erase(0);
282 SignalSender::waitFor(Uint32 timeOutMillis){
285 return waitFor(timeOutMillis, w);
288 #include <NdbApiSignal.hpp>
295 s->header = * signal;
296 for(Uint32 i = 0; i<s->header.m_noOfSections; i++){
297 s->ptr[
i].p =
new Uint32[ptr[
i].sz];
298 s->ptr[
i].sz = ptr[
i].sz;
299 memcpy(s->ptr[i].p, ptr[i].p, 4 * ptr[i].sz);
301 m_jobBuffer.push_back(s);
307 SignalSender::find_node(
const NodeBitmask& mask, T & t)
313 if (n == NodeBitmask::NotFound)
316 assert(n < MAX_NODES);
318 }
while (!t.found_ok(*
this, getNodeInfo(n)));
327 return node.is_confirmed();
333 SignalSender::find_confirmed_node(
const NodeBitmask& mask)
336 return find_node(mask, f);
343 return node.is_connected();
349 SignalSender::find_connected_node(
const NodeBitmask& mask)
352 return find_node(mask, f);
365 SignalSender::find_alive_node(
const NodeBitmask& mask)
368 return find_node(mask, f);
372 #if __SUNPRO_CC != 0x560
374 template NodeId SignalSender::find_node<FindConfirmedNode>(
const NodeBitmask&,
376 template NodeId SignalSender::find_node<FindAliveNode>(
const NodeBitmask&,
378 template NodeId SignalSender::find_node<FindConnectedNode>(
const NodeBitmask&,