esrf bug, shut down socket, but being processed and object deleted, fixed

This commit is contained in:
Dhanya Maliakal
2017-08-09 17:25:23 +02:00
parent 5a45f15c7f
commit 39847c5db6
5 changed files with 31 additions and 19 deletions

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsReceiverSoftware Path: slsDetectorsPackage/slsReceiverSoftware
URL: origin git@git.psi.ch:sls_detectors_software/sls_receiver_software.git URL: origin git@git.psi.ch:sls_detectors_software/sls_receiver_software.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_receiver_software.git Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_receiver_software.git
Repsitory UUID: 1e33a1e0f7de91e255f4a1553445f80d184d84d2 Repsitory UUID: abdbd15341f292983b3943639c54404c700fbdb8
Revision: 620 Revision: 622
Branch: 3.0-rc Branch: 3.0-rc
Last Changed Author: Dhanya_Maliakal Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 625 Last Changed Rev: 627
Last Changed Date: 2017-08-08 08:55:46.000000002 +0200 ./src/utilities.cpp Last Changed Date: 2017-08-09 17:19:52.000000002 +0200 ./src/Listener.cpp

View File

@ -278,5 +278,8 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
/** if the standard header is implemented in firmware */ /** if the standard header is implemented in firmware */
bool standardheader; bool standardheader;
/** if the udp socket is connected */
bool udpSocketAlive;
}; };

View File

@ -637,10 +637,10 @@ enum communicationProtocol{
break; break;
//incomplete packets or header packets ignored and read buffer again //incomplete packets or header packets ignored and read buffer again
if(nsent != packet_size && nsent != header_packet_size) if(nsent != packet_size && nsent != header_packet_size)
bprintf(RED,"Incomplete Packet size %d\n",nsent); bprintf(RED,"%d Incomplete Packet size %d\n", portno, nsent);
} }
//nsent = 1040; //nsent = 1040;
total_sent+=nsent; if(nsent > 0)total_sent+=nsent;
} }
break; break;
default: default:

View File

@ -1,11 +1,11 @@
//#define SVNPATH "" //#define SVNPATH ""
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_receiver_software.git" #define SVNURL "git@git.psi.ch:sls_detectors_software/sls_receiver_software.git"
//#define SVNREPPATH "" //#define SVNREPPATH ""
#define SVNREPUUID "1e33a1e0f7de91e255f4a1553445f80d184d84d2" #define SVNREPUUID "abdbd15341f292983b3943639c54404c700fbdb8"
//#define SVNREV 0x625 //#define SVNREV 0x627
//#define SVNKIND "" //#define SVNKIND ""
//#define SVNSCHED "" //#define SVNSCHED ""
#define SVNAUTH "Dhanya_Maliakal" #define SVNAUTH "Dhanya_Maliakal"
#define SVNREV 0x625 #define SVNREV 0x627
#define SVNDATE 0x20170808 #define SVNDATE 0x20170809
// //

View File

@ -48,7 +48,8 @@ Listener::Listener(detectorType dtype, Fifo*& f, runStatus* s, uint32_t* portno,
currentFrameIndex(0), currentFrameIndex(0),
carryOverFlag(0), carryOverFlag(0),
carryOverPacket(0), carryOverPacket(0),
listeningPacket(0) listeningPacket(0),
udpSocketAlive(0)
{ {
if(ThreadObject::CreateThread()){ if(ThreadObject::CreateThread()){
pthread_mutex_lock(&Mutex); pthread_mutex_lock(&Mutex);
@ -223,6 +224,7 @@ int Listener::CreateUDPSockets() {
FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber << " error: " << iret; FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber << " error: " << iret;
return FAIL; return FAIL;
} }
udpSocketAlive = true;
return OK; return OK;
} }
@ -230,11 +232,11 @@ int Listener::CreateUDPSockets() {
void Listener::ShutDownUDPSocket() { void Listener::ShutDownUDPSocket() {
if(udpSocket){ if(udpSocket){
udpSocketAlive = false;
udpSocket->ShutDownSocket(); udpSocket->ShutDownSocket();
FILE_LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber; FILE_LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber;
fflush(stdout); fflush(stdout);
delete udpSocket; //delete socket at stoplistening
udpSocket = 0;
} }
} }
@ -250,7 +252,7 @@ void Listener::ThreadExecution() {
#endif #endif
//udpsocket doesnt exist //udpsocket doesnt exist
if (*activated && !udpSocket && !carryOverFlag) { if (*activated && !udpSocketAlive && !carryOverFlag) {
//FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier"; //FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
(*((uint32_t*)buffer)) = 0; (*((uint32_t*)buffer)) = 0;
StopListening(buffer); StopListening(buffer);
@ -258,7 +260,7 @@ void Listener::ThreadExecution() {
} }
//get data //get data
if ((*status != TRANSMITTING && udpSocket) || carryOverFlag) { if ((*status != TRANSMITTING && udpSocketAlive) || carryOverFlag) {
if (*activated) if (*activated)
rc = ListenToAnImage(buffer); rc = ListenToAnImage(buffer);
else else
@ -274,8 +276,11 @@ void Listener::ThreadExecution() {
//error check, (should not be here) if not transmitting yet (previous if) rc should be > 0 //error check, (should not be here) if not transmitting yet (previous if) rc should be > 0
if (rc <= 0) { if (rc <= 0) {
//cprintf(RED,"Error:(Weird Early self shut down), UDP Sockets not shut down, but received nothing\n"); //cprintf(RED,"%d Socket shut down while waiting for future packet. udpsocketalive:%d\n",index, udpSocketAlive );
StopListening(buffer); if (!udpSocketAlive) {
(*((uint32_t*)buffer)) = 0;
StopListening(buffer);
}
return; return;
} }
@ -295,6 +300,10 @@ void Listener::StopListening(char* buf) {
(*((uint32_t*)buf)) = DUMMY_PACKET_VALUE; (*((uint32_t*)buf)) = DUMMY_PACKET_VALUE;
fifo->PushAddress(buf); fifo->PushAddress(buf);
StopRunning(); StopRunning();
if (udpSocket) {
delete udpSocket;
udpSocket = 0;
}
#ifdef VERBOSE #ifdef VERBOSE
bprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught); bprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught);
bprintf(GREEN,"%d: Listening Completed\n", index); bprintf(GREEN,"%d: Listening Completed\n", index);
@ -304,7 +313,7 @@ void Listener::StopListening(char* buf) {
/* buf includes the fifo header and packet header */ /* buf includes the fifo header and packet header */
uint32_t Listener::ListenToAnImage(char* buf) { uint32_t Listener::ListenToAnImage(char* buf) {
uint32_t rc = 0; int rc = 0;
uint64_t fnum = 0, bid = 0; uint64_t fnum = 0, bid = 0;
uint32_t pnum = 0, snum = 0; uint32_t pnum = 0, snum = 0;
uint32_t numpackets = 0; uint32_t numpackets = 0;
@ -395,7 +404,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
while ( numpackets < pperFrame) { while ( numpackets < pperFrame) {
//listen to new packet //listen to new packet
rc = 0; rc = 0;
if (udpSocket){ if (udpSocketAlive){
rc = udpSocket->ReceiveDataOnly(listeningPacket); rc = udpSocket->ReceiveDataOnly(listeningPacket);
} }
if(rc <= 0) { if(rc <= 0) {