some changes for memory leak

This commit is contained in:
Dhanya Maliakal 2015-11-11 15:08:50 +01:00
parent 455c9c5c80
commit 0627668090
4 changed files with 146 additions and 84 deletions

View File

@ -379,11 +379,10 @@ private:
* @param wbuffer the buffer array that is popped from all the FIFOs * @param wbuffer the buffer array that is popped from all the FIFOs
* @param ready if that FIFO is allowed to pop (depends on if dummy buffer already popped/ waiting for other FIFO to finish a frame(eiger)) * @param ready if that FIFO is allowed to pop (depends on if dummy buffer already popped/ waiting for other FIFO to finish a frame(eiger))
* @param nP number of packets in the buffer popped out * @param nP number of packets in the buffer popped out
* @param toFree array of addresses to pop into fifoFree (eiger specific) * @param fifoTempFree circular fifo to save addresses of packets adding upto a frame before pushing into fifofree (eiger specific)
* @param toFreeOffset the number of addresses to free for each FIFO (eiger specific)
* @return true if end of acquisition else false * @return true if end of acquisition else false
*/ */
bool popAndCheckEndofAcquisition(int ithread, char* wbuffer[], bool ready[], uint32_t nP[],char* toFree[],int toFreeOffset[]); bool popAndCheckEndofAcquisition(int ithread, char* wbuffer[], bool ready[], uint32_t nP[],CircularFifo<char>* fifoTempFree[]);
/** /**
* Called by processWritingBuffer and processWritingBufferPacketByPacket * Called by processWritingBuffer and processWritingBufferPacketByPacket

View File

@ -116,6 +116,11 @@ typedef struct
// serverAddress = {0}; // serverAddress = {0};
// clientAddress = {0}; // clientAddress = {0};
// strcpy(hostname,host_ip_or_name); // strcpy(hostname,host_ip_or_name);
strcpy(lastClientIP,"none");
strcpy(thisClientIP,"none1");
strcpy(dummyClientIP,"dummy");
struct hostent *hostInfo = gethostbyname(host_ip_or_name); struct hostent *hostInfo = gethostbyname(host_ip_or_name);
if (hostInfo == NULL){ if (hostInfo == NULL){
cerr << "Exiting: Problem interpreting host: " << host_ip_or_name << "\n"; cerr << "Exiting: Problem interpreting host: " << host_ip_or_name << "\n";
@ -170,16 +175,16 @@ typedef struct
nsent(0), nsent(0),
total_sent(0) total_sent(0)
{ {
//memset(&serverAddress, 0, sizeof(sockaddr_in));
// memset(&clientAddress, 0, sizeof(sockaddr_in));
// serverAddress = {0};
// clientAddress = {0};
/* // you can specify an IP address: */
/* */
/* // you can specify an IP address: */
/* // or you can let it automatically select one: */ /* // or you can let it automatically select one: */
/* myaddr.sin_addr.s_addr = INADDR_ANY; */ /* myaddr.sin_addr.s_addr = INADDR_ANY; */
strcpy(lastClientIP,"none");
strcpy(thisClientIP,"none1");
strcpy(dummyClientIP,"dummy");
if(serverAddress.sin_port == htons(port_number)){ if(serverAddress.sin_port == htons(port_number)){
socketDescriptor = -10; socketDescriptor = -10;
return; return;
@ -592,6 +597,15 @@ typedef struct
length-=nsent; length-=nsent;
total_sent+=nsent; total_sent+=nsent;
} }
if (total_sent>0)
strcpy(thisClientIP,dummyClientIP);
if (strcmp(lastClientIP,thisClientIP))
differentClients=1;
else
differentClients=0;
break; break;
case UDP: case UDP:
if (socketDescriptor<0) return -1; if (socketDescriptor<0) return -1;
@ -641,13 +655,7 @@ typedef struct
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
cout << "sent "<< total_sent << " Bytes" << endl; cout << "sent "<< total_sent << " Bytes" << endl;
#endif #endif
if (total_sent>0)
strcpy(thisClientIP,dummyClientIP);
if (strcmp(lastClientIP,thisClientIP))
differentClients=1;
else
differentClients=0;
return total_sent; return total_sent;

View File

@ -152,7 +152,7 @@ void UDPStandardImplementation::initializeMembers(){
previousFrameNumber = -1; previousFrameNumber = -1;
acqStarted = false; acqStarted = false;
measurementStarted = false; measurementStarted = false;
for(int i = 0; i < numberofListeningThreads; ++i) for(int i = 0; i < MAX_NUMBER_OF_LISTENING_THREADS; ++i)
totalListeningFrameCount[i] = 0; totalListeningFrameCount[i] = 0;
packetsInFile = 0; packetsInFile = 0;
numMissingPackets = 0; numMissingPackets = 0;
@ -309,6 +309,7 @@ int UDPStandardImplementation::setupFifoStructure(){
return OK; return OK;
int count = 0;
//set up fifo structure //set up fifo structure
for(int i=0;i<numberofListeningThreads;i++){ for(int i=0;i<numberofListeningThreads;i++){
@ -321,13 +322,19 @@ int UDPStandardImplementation::setupFifoStructure(){
#endif #endif
delete fifoFree[i]; delete fifoFree[i];
} }
if(fifo[i]) delete fifo[i]; if(fifo[i]){
while(!fifo[i]->isEmpty())
fifo[i]->pop(buffer[i]);
delete fifo[i];
}
if(mem0[i]) free(mem0[i]); if(mem0[i]) free(mem0[i]);
//creating //creating
fifoFree[i] = new CircularFifo<char>(fifoSize); fifoFree[i] = new CircularFifo<char>(fifoSize);
fifo[i] = new CircularFifo<char>(fifoSize); fifo[i] = new CircularFifo<char>(fifoSize);
//cout<<"buffersize:"<<bufferSize<<endl;
//allocate memory //allocate memory
mem0[i] = (char*)malloc((bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS) * fifoSize); mem0[i] = (char*)malloc((bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS) * fifoSize);
if (mem0[i] == NULL){ if (mem0[i] == NULL){
@ -336,14 +343,19 @@ int UDPStandardImplementation::setupFifoStructure(){
} }
//push free address into fifoFree //push free address into fifoFree
count = 0;
buffer[i]=mem0[i]; buffer[i]=mem0[i];
while (buffer[i] < (mem0[i]+(bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS) * (fifoSize-1))) { while (buffer[i] < (mem0[i]+(bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS) * (fifoSize-1))) {
fifoFree[i]->push(buffer[i]); fifoFree[i]->push(buffer[i]);
#ifdef DEBUG5 //#ifdef DEBUG5
if(count==0 || count == 127998)
cprintf(BLUE,"Info: %d fifostructure free pushed into fifofree %p\n", i, (void*)(buffer[i])); cprintf(BLUE,"Info: %d fifostructure free pushed into fifofree %p\n", i, (void*)(buffer[i]));
#endif //#endif
buffer[i] += (bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS); buffer[i] += (bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS);
count++;
} }
cout<<i<<" count:"<<count<<endl;
} }
FILE_LOG(logDEBUG) << "Info: Fifo structure(s) reconstructed"; FILE_LOG(logDEBUG) << "Info: Fifo structure(s) reconstructed";
return OK; return OK;
@ -1452,8 +1464,11 @@ void UDPStandardImplementation::startListening(){
//pop from fifo //pop from fifo
fifoFree[ithread]->pop(buffer[ithread]); fifoFree[ithread]->pop(buffer[ithread]);
#ifdef DEBUG5 #ifdef CFIFODEBUG
cprintf(BLUE,"Listening_Thread %d :Listener popped from fifofree %p\n", ithread, (void*)(buffer[ithread])); if(ithread == 0)
cprintf(CYAN,"Listening_Thread %d :Listener popped from fifofree %p\n", ithread, (void*)(buffer[ithread]));
else
cprintf(YELLOW,"Listening_Thread %d :Listener popped from fifofree %p\n", ithread, (void*)(buffer[ithread]));
#endif #endif
//udpsocket doesnt exist //udpsocket doesnt exist
@ -1489,8 +1504,12 @@ void UDPStandardImplementation::startListening(){
//push buffer to FIFO //push buffer to FIFO
while(!fifo[ithread]->push(buffer[ithread])); while(!fifo[ithread]->push(buffer[ithread]));
#ifdef DEBUG5 #ifdef CFIFODEBUG
cprintf(BLUE,"Listening_Thread %d: Listener pushed into fifo %p\n",ithread, (void*)(buffer[ithread])); if(ithread == 0)
cprintf(CYAN,"Listening_Thread %d: Listener pushed into fifo %p\n",ithread, (void*)(buffer[ithread]));
else
cprintf(YELLOW,"Listening_Thread %d: Listener pushed into fifo %p\n",ithread, (void*)(buffer[ithread]));
#endif #endif
}/*--end of loop for each buffer (inner loop)*/ }/*--end of loop for each buffer (inner loop)*/
@ -1517,6 +1536,7 @@ int UDPStandardImplementation::prepareAndListenBuffer(int ithread, int lSize, in
FILE_LOG(logDEBUG) << __AT__ << " called"; FILE_LOG(logDEBUG) << __AT__ << " called";
//listen to UDP packets //listen to UDP packets
if(cSize)
memcpy(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS, temp, cSize); memcpy(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS, temp, cSize);
int receivedSize = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS + cSize, lSize + cSize); int receivedSize = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS + cSize, lSize + cSize);
@ -1606,8 +1626,11 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){
if(numbytes <= 0){ if(numbytes <= 0){
cprintf(BLUE,"Listening_Thread %d :End of Acquisition\n", ithread); cprintf(BLUE,"Listening_Thread %d :End of Acquisition\n", ithread);
while(!fifoFree[ithread]->push(buffer[ithread])); while(!fifoFree[ithread]->push(buffer[ithread]));
#ifdef DEBUG5 #ifdef CFIFODEBUG
cprintf(BLUE,"Listening_Thread %d :Listener push empty buffer into fifofree %p\n", ithread, (void*)(buffer[ithread])); if(ithread == 0)
cprintf(CYAN,"Listening_Thread %d :Listener push empty buffer into fifofree %p\n", ithread, (void*)(buffer[ithread]));
else
cprintf(YELLOW,"Listening_Thread %d :Listener push empty buffer into fifofree %p\n", ithread, (void*)(buffer[ithread]));
#endif #endif
} }
@ -1621,19 +1644,31 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){
cprintf(BLUE,"Listening_Thread %d: Last Buffer packet count:%d\n",ithread, numbytes/onePacketSize); cprintf(BLUE,"Listening_Thread %d: Last Buffer packet count:%d\n",ithread, numbytes/onePacketSize);
#endif #endif
while(!fifo[ithread]->push(buffer[ithread])); while(!fifo[ithread]->push(buffer[ithread]));
#ifdef DEBUG5 #ifdef CFIFODEBUG
cprintf(BLUE,"Listening_Thread %d: Listener Last Buffer pushed into fifo %p\n", ithread,(void*)(buffer[ithread])); if(ithread == 0)
cprintf(CYAN,"Listening_Thread %d: Listener Last Buffer pushed into fifo %p\n", ithread,(void*)(buffer[ithread]));
else
cprintf(YELLOW,"Listening_Thread %d: Listener Last Buffer pushed into fifo %p\n", ithread,(void*)(buffer[ithread]));
#endif #endif
} }
//push dummy-end buffer into fifo for all writer threads //push dummy-end buffer into fifo for all writer threads
for(int i=0; i<numberofWriterThreads; ++i){ for(int i=0; i<numberofWriterThreads; ++i){
fifoFree[ithread]->pop(buffer[ithread]); fifoFree[ithread]->pop(buffer[ithread]);
#ifdef CFIFODEBUG
if(ithread == 0)
cprintf(CYAN,"Listening_Thread %d: Popped Dummy from fifoFree %p\n", ithread,(void*)(buffer[ithread]));
else
cprintf(YELLOW,"Listening_Thread %d: Popped Dummy from fifoFree %p\n", ithread,(void*)(buffer[ithread]));
#endif
//creating dummy-end buffer with pc=0xFFFF //creating dummy-end buffer with pc=0xFFFF
(*((uint32_t*)(buffer[ithread]))) = dummyPacketValue; (*((uint32_t*)(buffer[ithread]))) = dummyPacketValue;
while(!fifo[ithread]->push(buffer[ithread])); while(!fifo[ithread]->push(buffer[ithread]));
#ifdef DEBUG5 #ifdef CFIFODEBUG
cprintf(BLUE,"Listening_Thread %d: Listener pushed dummy-end buffer into fifo %p\n", ithread,(void*)(buffer[ithread])); if(ithread == 0)
cprintf(CYAN,"Listening_Thread %d: Listener pushed dummy-end buffer into fifo %p\n", ithread,(void*)(buffer[ithread]));
else
cprintf(YELLOW,"Listening_Thread %d: Listener pushed dummy-end buffer into fifo %p\n", ithread,(void*)(buffer[ithread]));
#endif #endif
} }
@ -1852,8 +1887,9 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
int MAX_NUM_PACKETS = 1024; //highest 32 bit has 1024 number of packets int MAX_NUM_PACKETS = 1024; //highest 32 bit has 1024 number of packets
uint32_t LAST_PACKET_VALUE; //last packet number uint32_t LAST_PACKET_VALUE; //last packet number
char* toFreePointers[MAX_NUM_PACKETS]; //pointers to free for each frame
int toFreePointersOffset[numberofListeningThreads]; //offset of pointers to free added for each thread CircularFifo<char>* fifoTempFree[numberofListeningThreads];//ciruclar fifo to keep track of one frame packets to be freed and reused later
char* temp = NULL;
char* frameBuffer[MAX_NUM_PACKETS]; //buffer offset created for a whole frame char* frameBuffer[MAX_NUM_PACKETS]; //buffer offset created for a whole frame
int frameBufferoffset[numberofListeningThreads]; //buffer offset created for a whole frame for both listening threads int frameBufferoffset[numberofListeningThreads]; //buffer offset created for a whole frame for both listening threads
@ -1868,34 +1904,42 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
volatile int numberofMissingPackets[numberofListeningThreads]; // number of missing packets in this buffer volatile int numberofMissingPackets[numberofListeningThreads]; // number of missing packets in this buffer
for(int i=0; i<MAX_NUM_PACKETS; ++i){ for(int i=0; i<MAX_NUM_PACKETS; ++i){
toFreePointers[i] = NULL;
frameBuffer[i] = NULL; frameBuffer[i] = NULL;
blankframe[i] = NULL; blankframe[i] = NULL;
} }
for(int i=0; i<numberofListeningThreads; ++i){
fifoTempFree[i] = NULL;
}
/* outer loop - loops once for each acquisition */ /* outer loop - loops once for each acquisition */
//infinite loop, exited only to change dynamic range, 10G parameters etc (then recreated again) //infinite loop, exited only to change dynamic range, 10G parameters etc (then recreated again)
while(true){ while(true){
//unsigned char* blankframe_data=0;
//eiger_packet_header_t* blankframe_header = 0;
//--reset parameters before acquisition //--reset parameters before acquisition
presentFrameNumber = 0;
blankoffset = 0; //blank frame - initializing with missing packet values
guiData = latestData; //so that the first frame is always copied
LAST_PACKET_VALUE = (packetsPerFrame/numberofListeningThreads);
for(int i=0; i<numberofListeningThreads; ++i){ for(int i=0; i<numberofListeningThreads; ++i){
packetBuffer[i] = NULL; packetBuffer[i] = NULL;
popReady[i] = true; popReady[i] = true;
numPackets[i] = 0; numPackets[i] = 0;
toFreePointersOffset[i] = (i*packetsPerFrame/numberofListeningThreads);
frameBufferoffset[i] = (i*packetsPerFrame/numberofListeningThreads); frameBufferoffset[i] = (i*packetsPerFrame/numberofListeningThreads);
fullframe[i] = false; fullframe[i] = false;
threadFrameNumber[i] = 0; threadFrameNumber[i] = 0;
lastPacketNumber[i] = 0; lastPacketNumber[i] = 0;
currentPacketNumber[i] = 0; currentPacketNumber[i] = 0;
numberofMissingPackets[i] = 0; numberofMissingPackets[i] = 0;
//circular temp fifo between getting a whole frame and freeing them
if(fifoTempFree[i]){
while(!fifoTempFree[i]->isEmpty())
fifoTempFree[i]->pop(temp);
delete fifoTempFree[i];
}
fifoTempFree[i] = new CircularFifo<char>(MAX_NUM_PACKETS);
} }
presentFrameNumber = 0;
//blank frame - initializing with missing packet values
blankoffset = 0;
for(uint32_t i=0; i<packetsPerFrame; ++i){ for(uint32_t i=0; i<packetsPerFrame; ++i){
if(blankframe[i]){delete [] blankframe[i]; blankframe[i] = 0;} if(blankframe[i]){delete [] blankframe[i]; blankframe[i] = 0;}
@ -1909,8 +1953,8 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
*(blankframe_data) = 0xFF; *(blankframe_data) = 0xFF;
} }
} }
guiData = latestData; //so that the first frame is always copied
LAST_PACKET_VALUE = (packetsPerFrame/numberofListeningThreads);
@ -1920,7 +1964,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
//pop fifo and if end of acquisition //pop fifo and if end of acquisition
if(popAndCheckEndofAcquisition(ithread, packetBuffer, popReady, numPackets,toFreePointers,toFreePointersOffset)){ if(popAndCheckEndofAcquisition(ithread, packetBuffer, popReady, numPackets,fifoTempFree)){
#ifdef DEBUG4 #ifdef DEBUG4
cprintf(GREEN,"Writing_Thread All dummy-end buffers popped\n", ithread); cprintf(GREEN,"Writing_Thread All dummy-end buffers popped\n", ithread);
#endif #endif
@ -2069,37 +2113,38 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
//#ifdef FNUM_DEBUG //#ifdef FNUM_DEBUG
cprintf(GREEN,"**fnum:%d**\n",currentFrameNumber); cprintf(GREEN,"**fnum:%d**\n",currentFrameNumber);
//#endif //#endif
#ifdef MISSINGP_DEBUG //#ifdef MISSINGP_DEBUG
if(numberofMissingPackets[0])
cprintf(RED, "Fifo 0 missing packets %d for fnum %d\n",numberofMissingPackets[0],currentPacketNumber);
if(numberofMissingPackets[1])
cprintf(RED, "Fifo 1 missing packets%d for fnum %d\n",numberofMissingPackets[1],currentPacketNumber);
if(numMissingPackets){ if(numMissingPackets){
cprintf(RED, "Total missing packets %d for fnum %d\n",numMissingPackets,currentPacketNumber); cprintf(RED, "Total missing packets %d for fnum %d\n",numMissingPackets,currentFrameNumber);
for (int j=0;j<packetsPerFrame;++j){ for (int j=0;j<packetsPerFrame;++j){
eiger_packet_header_t* frameBuffer_header = (eiger_packet_header_t*) frameBuffer[j]; eiger_packet_header_t* frameBuffer_header = (eiger_packet_header_t*) frameBuffer[j];
if (*( (uint16_t*) frameBuffer_header->missingPacket)==missingPacketValue) if (*( (uint16_t*) frameBuffer_header->missingPacket)==missingPacketValue)
cprintf(RED,"Found missing packet at pnum %d\n",j); cprintf(RED,"Found missing packet at pnum %d\n",j);
} }
} }
#endif //#endif
//write and copy to gui //write and copy to gui
handleWithoutDataCompression(ithread,frameBuffer,packetsPerFrame); handleWithoutDataCompression(ithread,frameBuffer,packetsPerFrame);
//freeing //freeing
for(int j=0;j<toFreePointersOffset[0];++j){ for(int i=0; i<numberofListeningThreads; ++i){
while(!fifoFree[0]->push(toFreePointers[j])); int count =0;
#ifdef DEBUG5 while(!fifoTempFree[i]->isEmpty()){
cprintf(GREEN,"Fifo 0: Writing_Thread freed: pushed into fifofree %p\n",ithread, (void*)(toFreePointers[j])); fifoTempFree[i]->pop(temp);
fifoFree[i]->push(temp);
count++;
#ifdef CFIFODEBUG
if(i==0)
cprintf(CYAN,"Fifo %d: %d Writing_Thread freed: pushed into fifofree %p\n",i,count, (void*)(temp));
else
cprintf(YELLOW,"Fifo %d: %d Writing_Thread freed: pushed into fifofree %p\n",i, count,(void*)(temp));
#endif #endif
} }
for(int j=(packetsPerFrame/numberofListeningThreads);j<toFreePointersOffset[1];++j){
while(!fifoFree[1]->push(toFreePointers[j]));
#ifdef DEBUG5
cprintf(GREEN,"Fifo 1: Writing_Thread freed: pushed into fifofree %p\n",ithread, (void*)(toFreePointers[j]));
#endif
} }
#ifdef DEBUG4 #ifdef DEBUG4
cprintf(GREEN,"Writing_Thread: finished freeing\n"); cprintf(GREEN,"Writing_Thread: finished freeing\n");
#endif #endif
@ -2113,7 +2158,6 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
if((numPackets[i] != dummyPacketValue) && (currentPacketNumber[i] == LAST_PACKET_VALUE)) if((numPackets[i] != dummyPacketValue) && (currentPacketNumber[i] == LAST_PACKET_VALUE))
popReady[i] = true; popReady[i] = true;
frameBufferoffset[i] = (i*packetsPerFrame/numberofListeningThreads); frameBufferoffset[i] = (i*packetsPerFrame/numberofListeningThreads);
toFreePointersOffset[i] = (i*packetsPerFrame/numberofListeningThreads);
blankoffset = 0; blankoffset = 0;
lastPacketNumber[i] = 0; lastPacketNumber[i] = 0;
currentPacketNumber[i] = 0; currentPacketNumber[i] = 0;
@ -2202,7 +2246,7 @@ void UDPStandardImplementation::waitWritingBufferForNextAcquisition(int ithread)
} }
bool UDPStandardImplementation::popAndCheckEndofAcquisition(int ithread, char* wbuffer[], bool ready[], uint32_t nP[],char* toFree[],int toFreeOffset[]){ bool UDPStandardImplementation::popAndCheckEndofAcquisition(int ithread, char* wbuffer[], bool ready[], uint32_t nP[],CircularFifo<char>* fifoTempFree[]){
FILE_LOG(logDEBUG) << __AT__ << " called"; FILE_LOG(logDEBUG) << __AT__ << " called";
bool endofAcquisition = true; bool endofAcquisition = true;
@ -2210,8 +2254,11 @@ bool UDPStandardImplementation::popAndCheckEndofAcquisition(int ithread, char* w
//pop if ready //pop if ready
if(ready[i]){ if(ready[i]){
fifo[i]->pop(wbuffer[i]); fifo[i]->pop(wbuffer[i]);
#ifdef DEBUG5 #ifdef CFIFODEBUG
cprintf(GREEN,"Writing_Thread %d: Popped %p from FIFO %d\n", ithread, (void*)(wbuffer[i]),i); if(i == 0)
cprintf(CYAN,"Writing_Thread %d: Popped %p from FIFO %d\n", ithread, (void*)(wbuffer[i]),i);
else
cprintf(YELLOW,"Writing_Thread %d: Popped %p from FIFO %d\n", ithread, (void*)(wbuffer[i]),i);
#endif #endif
nP[i] = (uint32_t)(*((uint32_t*)wbuffer[i])); nP[i] = (uint32_t)(*((uint32_t*)wbuffer[i]));
#ifdef DEBUG4 #ifdef DEBUG4
@ -2239,8 +2286,7 @@ bool UDPStandardImplementation::popAndCheckEndofAcquisition(int ithread, char* w
} }
#endif #endif
if(myDetectorType == EIGER){ if(myDetectorType == EIGER){
toFree[toFreeOffset[i]] = wbuffer[i]; while(!fifoTempFree[i]->push(wbuffer[i]));
toFreeOffset[i]++;
} }
} }
} }
@ -2264,8 +2310,11 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){
//free fifo //free fifo
for(int i=0; i<numberofListeningThreads; ++i){ for(int i=0; i<numberofListeningThreads; ++i){
while(!fifoFree[i]->push(wbuffer[i])); while(!fifoFree[i]->push(wbuffer[i]));
#ifdef DEBUG5 #ifdef CFIFODEBUG
cprintf(GREEN,"Writing_Thread %d: Freeing dummy-end buffer. Pushed into fifofree %p for listener %d\n", ithread,(void*)(wbuffer[i]),i); if(i==0)
cprintf(CYAN,"Writing_Thread %d: Freeing dummy-end buffer. Pushed into fifofree %p for listener %d\n", ithread,(void*)(wbuffer[i]),i);
else
cprintf(YELLOW,"Writing_Thread %d: Freeing dummy-end buffer. Pushed into fifofree %p for listener %d\n", ithread,(void*)(wbuffer[i]),i);
#endif #endif
} }
@ -2478,14 +2527,14 @@ void UDPStandardImplementation::writeFileWithoutCompression(char* wbuffer[],uint
void UDPStandardImplementation::createHeaders(char* wbuffer[]){ void UDPStandardImplementation::createHeaders(char* wbuffer[]){
eiger_packet_header_t* wbuf_header=0;
eiger_packet_footer_t* wbuf_footer=0;
int port = 0, missingPacket; int port = 0, missingPacket;
for (uint32_t i = 0; i < packetsPerFrame; i++){ for (uint32_t i = 0; i < packetsPerFrame; i++){
wbuf_header = (eiger_packet_header_t*) wbuffer[i];
wbuf_footer = (eiger_packet_footer_t*)(wbuffer[i] + footerOffset); eiger_packet_header_t* wbuf_header = (eiger_packet_header_t*) wbuffer[i];
eiger_packet_footer_t* wbuf_footer = (eiger_packet_footer_t*)(wbuffer[i] + footerOffset);
#ifdef DEBUG4 #ifdef DEBUG4
cprintf(GREEN, "Loop index:%d Pnum:%d\n",i,*( (uint16_t*) wbuf_footer->packetNumber)); cprintf(GREEN, "Loop index:%d Pnum:%d\n",i,*( (uint16_t*) wbuf_footer->packetNumber));
#endif #endif

View File

@ -441,6 +441,7 @@ int slsReceiverTCPIPInterface::set_file_name() {
#endif #endif
#endif #endif
if(ret==OK && socket->differentClients){ if(ret==OK && socket->differentClients){
FILE_LOG(logDEBUG) << "Force update"; FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE; ret=FORCE_UPDATE;
@ -451,12 +452,14 @@ int slsReceiverTCPIPInterface::set_file_name() {
if(ret==FAIL){ if(ret==FAIL){
cprintf(RED, "%s\n", mess); cprintf(RED, "%s\n", mess);
socket->SendDataOnly(mess,sizeof(mess)); socket->SendDataOnly(mess,sizeof(mess));
}
if(retval == NULL)
socket->SendDataOnly(defaultVal,MAX_STR_LENGTH); socket->SendDataOnly(defaultVal,MAX_STR_LENGTH);
}else else{
socket->SendDataOnly(retval,MAX_STR_LENGTH); socket->SendDataOnly(retval,MAX_STR_LENGTH);
delete[] retval;
}
//free
if(retval != NULL) delete[] retval;
//return ok/fail //return ok/fail
return ret; return ret;
@ -523,12 +526,13 @@ int slsReceiverTCPIPInterface::set_file_dir() {
if(ret==FAIL){ if(ret==FAIL){
cprintf(RED, "%s\n", mess); cprintf(RED, "%s\n", mess);
socket->SendDataOnly(mess,sizeof(mess)); socket->SendDataOnly(mess,sizeof(mess));
}
if(retval == NULL)
socket->SendDataOnly(defaultVal,MAX_STR_LENGTH); socket->SendDataOnly(defaultVal,MAX_STR_LENGTH);
}else else{
socket->SendDataOnly(retval,MAX_STR_LENGTH); socket->SendDataOnly(retval,MAX_STR_LENGTH);
delete[] retval;
//free }
if(retval != NULL) delete[] retval;
//return ok/fail //return ok/fail
return ret; return ret;
@ -2246,11 +2250,13 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
if(ret==FAIL){ if(ret==FAIL){
cprintf(RED, "%s\n", mess); cprintf(RED, "%s\n", mess);
socket->SendDataOnly(mess,sizeof(mess)); socket->SendDataOnly(mess,sizeof(mess));
}
if(retval == NULL)
socket->SendDataOnly(defaultVal,MAX_STR_LENGTH); socket->SendDataOnly(defaultVal,MAX_STR_LENGTH);
}else socket->SendDataOnly(retval,MAX_STR_LENGTH); else{
socket->SendDataOnly(retval,MAX_STR_LENGTH);
//free delete[] retval;
if(retval!=NULL) delete[] retval; }
//return ok/fail //return ok/fail
return ret; return ret;