17 #include "LongSignal.hpp"
18 #include "LongSignalImpl.hpp"
28 if (firstIVal == RNIL)
34 assert(first != NULL);
35 Uint32 totalSize= first->m_sz;
36 Uint32 lastSegIVal= first->m_lastSegment;
42 assert(lastSegIVal != RNIL);
45 if (totalSize <= SectionSegment::DataLength)
48 assert(first->m_lastSegment == firstIVal);
55 assert(first->m_nextSegment != RNIL);
56 assert(first->m_lastSegment != firstIVal);
57 Uint32 currIVal= firstIVal;
61 while (totalSize > SectionSegment::DataLength)
63 currIVal= curr->m_nextSegment;
64 curr= thePool.
getPtr(currIVal);
65 totalSize-= SectionSegment::DataLength;
74 assert(currIVal == lastSegIVal);
84 copy(Uint32 * & insertPtr,
90 assert(verifySection(_ptr.i, thePool));
93 memcpy(insertPtr, &ptrP->theData[0], 4 * 60);
96 ptrP = thePool.
getPtr(ptrP->m_nextSegment);
98 memcpy(insertPtr, &ptrP->theData[0], 4 * len);
104 copy(dst, g_sectionSegmentPool, src);
109 copy(Uint32* dst, Uint32 srcFirstIVal)
112 getSection(p, srcFirstIVal);
119 for(Uint32
i = 0;
i<len;
i++){
120 fprintf(out,
"H\'0x%.8x ", s->theData[
i]);
121 if(((
i + 1) % 6) == 0)
129 ptr.p = g_sectionSegmentPool.
getPtr(ptr.i);
130 Uint32 len = ptr.p->m_sz;
132 fprintf(out,
"ptr.i = %d(%p) ptr.sz = %d(%d)\n", ptr.i, ptr.p, len, ptr.sz);
133 while(len > SectionSegment::DataLength){
134 print(ptr.p, SectionSegment::DataLength, out);
136 len -= SectionSegment::DataLength;
137 fprintf(out,
"ptr.i = %d\n", ptr.p->m_nextSegment);
138 ptr.p = g_sectionSegmentPool.
getPtr(ptr.p->m_nextSegment);
141 print(ptr.p, len, out);
146 dupSection(SPC_ARG Uint32& copyFirstIVal, Uint32 srcFirstIVal)
148 assert(verifySection(srcFirstIVal));
156 while (sz > SectionSegment::DataLength)
158 ok= appendToSection(SPC_CACHE_ARG copyFirstIVal, &p->theData[0],
159 SectionSegment::DataLength);
163 sz-= SectionSegment::DataLength;
164 srcFirstIVal= p->m_nextSegment;
165 p= g_sectionSegmentPool.
getPtr(srcFirstIVal);
170 ok= appendToSection(SPC_CACHE_ARG copyFirstIVal, &p->theData[0], sz);
174 releaseSection(SPC_CACHE_ARG copyFirstIVal);
179 assert(verifySection(copyFirstIVal));
183 bool ErrorImportActive =
false;
184 extern int ErrorSignalReceive;
185 extern int ErrorMaxSegmentsToSeize;
207 appendToSection(SPC_ARG Uint32& firstSegmentIVal,
const Uint32* src, Uint32 len)
214 Uint32 remain= SectionSegment::DataLength;
215 Uint32 segmentLen= 0;
217 if (firstSegmentIVal == RNIL)
221 if (ErrorImportActive)
223 if ((ErrorSignalReceive == 1) &&
224 (ErrorMaxSegmentsToSeize == 0))
226 ndbout_c(
"append exhausted on first segment");
232 bool result= g_sectionSegmentPool.
seize(SPC_SEIZE_ARG firstPtr);
238 firstPtr.p->m_ownerRef= 0;
239 firstSegmentIVal= firstPtr.i;
246 g_sectionSegmentPool.
getPtr(firstPtr, firstSegmentIVal);
247 g_sectionSegmentPool.
getPtr(currPtr, firstPtr.p->m_lastSegment);
249 Uint32 existingLen= firstPtr.p->m_sz;
250 assert(existingLen > 0);
251 segmentLen= existingLen % SectionSegment::DataLength;
256 segmentLen= segmentLen == 0 ?
257 SectionSegment::DataLength :
260 remain= SectionSegment::DataLength - segmentLen;
263 firstPtr.p->m_sz+= len;
266 Uint32 remainSegs= (Uint32) ErrorMaxSegmentsToSeize - 1;
269 while(len > remain) {
273 memcpy(&currPtr.p->theData[segmentLen], src, remain << 2);
280 if (ErrorImportActive)
282 if ((ErrorSignalReceive == 1) &&
285 ndbout_c(
"Append exhausted on segment %d", ErrorMaxSegmentsToSeize);
286 firstPtr.p->m_lastSegment= prevPtr.i;
287 firstPtr.p->m_sz-= len;
292 bool result = g_sectionSegmentPool.
seize(SPC_SEIZE_ARG currPtr);
298 firstPtr.p->m_lastSegment= prevPtr.i;
299 firstPtr.p->m_sz-= len;
302 prevPtr.p->m_nextSegment = currPtr.i;
304 currPtr.p->m_ownerRef= 0;
307 remain= SectionSegment::DataLength;
311 firstPtr.p->m_lastSegment= currPtr.i;
312 currPtr.p->m_nextSegment= RNIL;
313 memcpy(&currPtr.p->theData[segmentLen], src, len << 2);
323 if (ErrorImportActive)
325 if ((ErrorSignalReceive == 1) &&
326 (ErrorMaxSegmentsToSeize == 0))
328 ndbout_c(
"Import exhausted on first segment");
335 if(g_sectionSegmentPool.
seize(SPC_SEIZE_ARG first)){
338 ndbout_c(
"No Segmented Sections for import");
343 first.p->m_ownerRef = 0;
348 Uint32 remainSegs= (Uint32) ErrorMaxSegmentsToSeize - 1;
351 while(len > SectionSegment::DataLength){
352 memcpy(&currPtr.p->theData[0], src, 4 * SectionSegment::DataLength);
353 src += SectionSegment::DataLength;
354 len -= SectionSegment::DataLength;
359 if (ErrorImportActive)
361 if ((ErrorSignalReceive == 1) &&
364 ndbout_c(
"Import exhausted on segment %d",
365 ErrorMaxSegmentsToSeize);
366 first.p->m_lastSegment= prevPtr.i;
368 prevPtr.p->m_nextSegment = RNIL;
374 if(g_sectionSegmentPool.
seize(SPC_SEIZE_ARG currPtr)){
375 prevPtr.p->m_nextSegment = currPtr.i;
379 first.p->m_lastSegment = prevPtr.i;
381 prevPtr.p->m_nextSegment = RNIL;
382 ndbout_c(
"Not enough Segmented Sections during import");
387 first.p->m_lastSegment = currPtr.i;
388 currPtr.p->m_nextSegment = RNIL;
389 memcpy(&currPtr.p->theData[0], src, 4 * len);
391 assert(verifySection(first.i));
398 g_sectionSegmentPool.releaseList(SPC_SEIZE_ARG
401 ptr.p->m_lastSegment);
405 releaseSection(SPC_ARG Uint32 firstSegmentIVal)
407 if (firstSegmentIVal != RNIL)
411 g_sectionSegmentPool.releaseList(SPC_SEIZE_ARG
419 writeToSection(Uint32 firstSegmentIVal, Uint32
offset,
428 if (firstSegmentIVal == RNIL)
435 g_sectionSegmentPool.
getPtr(segPtr, firstSegmentIVal);
437 Uint32 existingLen= segPtr.p->m_sz;
439 assert(existingLen > 0);
440 if (offset >= existingLen)
442 if (len > (existingLen - offset))
446 while (offset >= SectionSegment::DataLength)
448 g_sectionSegmentPool.
getPtr(segPtr, segPtr.p->m_nextSegment);
449 offset-= SectionSegment::DataLength;
455 Uint32 wordsToCopy = MIN(len,
456 SectionSegment::DataLength - offset);
457 memcpy(&segPtr.p->theData[offset], src, (wordsToCopy << 2));
467 g_sectionSegmentPool.
getPtr(segPtr, segPtr.p->m_nextSegment);