Exception handling from constructors for slsDetector and multiSlsDetector, zmqsockets deleted first in multi freeshm/constructor, removed unnecessary exceptions from exceptions list, replaced in slsDetector socket assign from NULL to 0

This commit is contained in:
2018-08-10 17:07:29 +02:00
parent 39ebd81230
commit da4253fe13
10 changed files with 190 additions and 167 deletions

View File

@ -271,16 +271,14 @@ public:
dset->extend(dims);
delete dspace;
dspace = 0;
DataSpace* d = new DataSpace(dset->getSpace());
dspace = d;
dspace = new DataSpace(dset->getSpace());
hsize_t dims_para[1] = {dims[0]};
for (unsigned int i = 0; i < dset_para.size(); ++i)
dset_para[i]->extend(dims_para);
delete dspace_para;
dspace_para = 0;
DataSpace* ds = new DataSpace(dset_para[0]->getSpace());
dspace_para = ds;
dspace_para = new DataSpace(dset_para[0]->getSpace());
}
catch(Exception error){
@ -322,16 +320,15 @@ public:
FileAccPropList flist;
flist.setFcloseDegree(H5F_CLOSE_STRONG);
int k = 0;
fd = 0;
if(!owenable)
k = new H5File( fname.c_str(), H5F_ACC_EXCL,
fd = new H5File( fname.c_str(), H5F_ACC_EXCL,
FileCreatPropList::DEFAULT,
flist );
else
k = new H5File( fname.c_str(), H5F_ACC_TRUNC,
fd = new H5File( fname.c_str(), H5F_ACC_TRUNC,
FileCreatPropList::DEFAULT,
flist );
fd = k;
//variables
DataSpace dataspace = DataSpace (H5S_SCALAR);
@ -466,16 +463,15 @@ public:
//file
FileAccPropList fapl;
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
int k = 0;
fd = 0;
if(!owenable)
k = new H5File( fname.c_str(), H5F_ACC_EXCL,
fd = new H5File( fname.c_str(), H5F_ACC_EXCL,
FileCreatPropList::DEFAULT,
fapl );
else
k = new H5File( fname.c_str(), H5F_ACC_TRUNC,
fd = new H5File( fname.c_str(), H5F_ACC_TRUNC,
FileCreatPropList::DEFAULT,
fapl );
fd = k;
//attributes - version
double dValue=version;
@ -486,8 +482,8 @@ public:
//dataspace
hsize_t srcdims[3] = {nDimx, nDimy, nDimz};
hsize_t srcdimsmax[3] = {H5S_UNLIMITED, nDimy, nDimz};
DataSpace* d = new DataSpace (3,srcdims,srcdimsmax);
dspace = d;
dspace = 0;
dspace = new DataSpace (3,srcdims,srcdimsmax);
//dataset name
@ -504,14 +500,14 @@ public:
// always create chunked dataset as unlimited is only supported with chunked layout
hsize_t chunk_dims[3] ={maxchunkedimages, nDimy, nDimz};
plist.setChunk(3, chunk_dims);
DataSet* ds = new DataSet (fd->createDataSet(dsetname.c_str(), dtype, *dspace, plist));
dset = ds;
dset = 0;
dset = new DataSet (fd->createDataSet(dsetname.c_str(), dtype, *dspace, plist));
//create parameter datasets
hsize_t dims[1] = {nDimx};
hsize_t dimsmax[1] = {H5S_UNLIMITED};
DataSpace* dsp = new DataSpace (1,dims,dimsmax);
dspace_para = dsp;
dspace_para = 0;
dspace_para = new DataSpace (1,dims,dimsmax);
// always create chunked dataset as unlimited is only supported with chunked layout
DSetCreatPropList paralist;
@ -842,6 +838,7 @@ public:
//new file
FileAccPropList fapl;
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
newfd = 0;
if(!owenable)
newfd = new H5File( newFileName.c_str(), H5F_ACC_EXCL,
FileCreatPropList::DEFAULT,
@ -851,7 +848,7 @@ public:
FileCreatPropList::DEFAULT,
fapl );
//dataspace and dataset
DataSpace* newDataspace;
DataSpace* newDataspace = 0;
if (rank == 3) {
hsize_t dims[3] = {nDimx, nDimy, nDimz};
newDataspace = new DataSpace (3,dims);
@ -859,7 +856,8 @@ public:
hsize_t dims[2] = {nDimx, nDimy};
newDataspace = new DataSpace (2,dims);
}
DataSet* newDataset = new DataSet( newfd->createDataSet(newDatasetName.c_str(), datatype, *newDataspace));
DataSet* newDataset = 0;
newDataset = new DataSet( newfd->createDataSet(newDatasetName.c_str(), datatype, *newDataspace));
//write and close
newDataset->write(data_out,datatype);
newfd->close();

View File

@ -10,26 +10,30 @@
#include <iostream>
#include <exception>
struct SlsDetectorPackageExceptions : public std::exception {
public:
SlsDetectorPackageExceptions() {}
std::string GetMessage() const { return "SLS Detector Package Failed";};
};
struct SharedMemoryException : public std::exception {
struct SharedMemoryException : public SlsDetectorPackageExceptions {
public:
SharedMemoryException() {}
std::string GetMessage() const { return "Shared Memory Failed";};
};
struct ThreadpoolException : public std::exception {
struct ThreadpoolException : public SlsDetectorPackageExceptions {
public:
ThreadpoolException() {}
std::string GetMessage() const { return "Threadpool Failed";};
};
struct SocketException : public std::exception {
struct SocketException : public SlsDetectorPackageExceptions {
public:
SocketException() {}
std::string GetMessage() const { return "Socket Failed";};
};
struct SamePortSocketException : public SocketException {
public:
SamePortSocketException() {}

View File

@ -132,8 +132,7 @@ void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srci
uint32_t portnum = port + index;
try {
ZmqSocket* z = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
zmqSocket = z;
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
} catch (...) {
cprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index);
throw;

View File

@ -194,10 +194,9 @@ int Listener::CreateUDPSockets() {
ShutDownUDPSocket();
try{
genericSocket* g = new genericSocket(*udpPortNumber, genericSocket::UDP,
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize,
*udpSocketBufferSize);
udpSocket = g;
FILE_LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
} catch (...) {
FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber;
@ -254,10 +253,9 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
//create dummy socket
try {
genericSocket* g = new genericSocket(*udpPortNumber, genericSocket::UDP,
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize,
*udpSocketBufferSize);
udpSocket = g;
} catch (...) {
FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber;
return FAIL;