From: <ro...@us...> - 2011-11-23 10:52:13
|
Revision: 2598 http://nscldaq.svn.sourceforge.net/nscldaq/?rev=2598&view=rev Author: ron-fox Date: 2011-11-23 10:52:06 +0000 (Wed, 23 Nov 2011) Log Message: ----------- - Introductory docs for the grand unified documentation begun. - Fix 2 stupidities in ringtostdout when writes needed to be segmented, both the wrong pointer and wrong count were used in subsequent writes. - Fix copy problem in stdintoring -when residual was less than a header the residual was not being moved resulting in corrupted events, hangs and crashes. Modified Paths: -------------- trunk/nextgen/ChangeLog trunk/nextgen/base/dataflow/ringtostdout.cpp trunk/nextgen/base/dataflow/stdintoring.cpp trunk/nextgen/daq/format/CRingSelectionPredicate.cpp trunk/nextgen/utilities/compatibility/spectcldaq.server.tcl Modified: trunk/nextgen/ChangeLog =================================================================== --- trunk/nextgen/ChangeLog 2011-11-21 19:23:49 UTC (rev 2597) +++ trunk/nextgen/ChangeLog 2011-11-23 10:52:06 UTC (rev 2598) @@ -147,6 +147,12 @@ - Explicitly use ssh not rsh in the rsh package of ReadoutShell. - Add complete docs for the readout GUI. -November 21-xx 2011 10.0-023 - - Introductory docs for the grand unified documentation. +November 21-23 2011 10.0-023 + - Introductory docs for the grand unified documentation begun. + - Fix 2 stupidities in ringtostdout when writes needed to be + segmented, both the wrong pointer and wrong count were used in + subsequent writes. + - Fix copy problem in stdintoring -when residual was less than a + header the residual was not being moved resulting in corrupted + events, hangs and crashes. Modified: trunk/nextgen/base/dataflow/ringtostdout.cpp =================================================================== --- trunk/nextgen/base/dataflow/ringtostdout.cpp 2011-11-21 19:23:49 UTC (rev 2597) +++ trunk/nextgen/base/dataflow/ringtostdout.cpp 2011-11-23 10:52:06 UTC (rev 2598) @@ -94,7 +94,7 @@ char* p = reinterpret_cast<char*>(pData); size_t residual = size; while (residual) { - ssize_t n = write(fd, pData, size); + ssize_t n = write(fd, p, residual); if (n < 0) { if (errno != EINTR) { perror("Write to output failed"); Modified: trunk/nextgen/base/dataflow/stdintoring.cpp =================================================================== --- trunk/nextgen/base/dataflow/stdintoring.cpp 2011-11-21 19:23:49 UTC (rev 2597) +++ trunk/nextgen/base/dataflow/stdintoring.cpp 2011-11-23 10:52:06 UTC (rev 2598) @@ -115,6 +115,17 @@ } } +void dumpWords(void* src, size_t nwords) +{ + uint16_t* s = reinterpret_cast<uint16_t*>(src); + std::cerr << std::hex; + for (int i=0; i < nwords; i++) { + if ((i % 8) == 0 ) std::cerr << std::endl; + std::cerr << *s++ << " "; + } + std::cerr << std::dec; +} + /** * Put data into the ring. * Each data item is assumed to be preceded by a two longword header of the form: @@ -146,12 +157,16 @@ struct header *pHeader; uint8_t* p = reinterpret_cast<uint8_t*>(pBuffer); // makes addr arithmetic easier. + struct header *pLastItem; + while(nBytes > sizeof(struct header)) { pHeader = reinterpret_cast<struct header*>(p); uint32_t size = computeSize(pHeader); - if (size <= nBytes) { + + if (size < nBytes) { // we can put a complete item + pLastItem = pHeader; ring.put(p, size); p += size; nBytes -= size; @@ -162,10 +177,13 @@ // must use memmove because this could be an overlapping // move - memmove(pBuffer, p, nBytes); + // memmove(pBuffer, p, nBytes); break; } + } + if (nBytes > 0) { + memmove(pBuffer, p, nBytes); } return nBytes; // Residual data. } @@ -264,6 +282,9 @@ size_t leftoverData = putData(source, pBuffer, nread + leftoverData); readOffset = leftoverData; readSize = mindata - leftoverData; + if (readSize == 0) { + exit(EXIT_FAILURE); + } } if (nread < 0) { perror("read failed"); @@ -312,9 +333,14 @@ int timeout = parsed.timeout_arg; size_t mindata = integerize(parsed.mindata_arg); + int exitStatus; + try { + exitStatus = mainLoop(ringname, timeout, mindata); + } + catch (std::string msg) { + std::cerr << "string exception caught: " << msg << std::endl; + } - int exitStatus = mainLoop(ringname, timeout, mindata); - // If requested, delete the ring on exit: if (parsed.deleteonexit_given) { Modified: trunk/nextgen/daq/format/CRingSelectionPredicate.cpp =================================================================== --- trunk/nextgen/daq/format/CRingSelectionPredicate.cpp 2011-11-21 19:23:49 UTC (rev 2597) +++ trunk/nextgen/daq/format/CRingSelectionPredicate.cpp 2011-11-23 10:52:06 UTC (rev 2598) @@ -238,8 +238,7 @@ return false; } if (p->second.s_sampled) { - if ((availableData > header.s_size) && - (freeSpace >= m_highWaterMark)) { + if (freeSpace >= m_highWaterMark) { return false; // full item is in ring, and below high water. } else if (availableData < header.s_size) { @@ -248,11 +247,9 @@ ring.pollblock(); return true; } - else { + else if (freeSpace < m_highWaterMark) { ring.skip(header.s_size); - if (!ring.availableData()) { - ring.pollblock(); - } + ring.pollblock(); return true; } } else { Modified: trunk/nextgen/utilities/compatibility/spectcldaq.server.tcl =================================================================== --- trunk/nextgen/utilities/compatibility/spectcldaq.server.tcl 2011-11-21 19:23:49 UTC (rev 2597) +++ trunk/nextgen/utilities/compatibility/spectcldaq.server.tcl 2011-11-23 10:52:06 UTC (rev 2598) @@ -50,7 +50,7 @@ [string is integer $env(BUFFERSIZE)]} { set bsize "--buffersize=$env(BUFFERSIZE)" } - exec -- $selector --sample=PHYSICS_EVENT | $formatter $bsize >@ $socket & + exec -- $selector --sample=PHYSICS_EVENT --source=$url | $formatter $bsize >@ $socket & # give the child process a chance to get going before closing the socket. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |