// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
#include "AliHLTHOMERReader.h"
-#include <stdio.h>
+//#include <stdio.h>
+#ifdef __SUNPRO_CC
#include <string.h>
-#include <errno.h>
+#else
+#include <cstring>
+#endif
+#include <cerrno>
#include <netdb.h>
extern int h_errno;
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
+//#include <sys/types.h>
+//#include <sys/socket.h>
+//#include <netinet/in.h>
+//#include <netinet/tcp.h>
#include <unistd.h>
#include <rpc/types.h>
#include <fcntl.h>
#define GET_ONE "GET ONE\n"
#define GET_ALL "GET ALL\n"
+// MAXHOSTNAMELEN not defined on macosx
+// 686-apple-darwin9-gcc-4.0.1
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 64
+#endif
+
#ifdef USE_ROOT
ClassImp(AliHLTMonitoringReader);
ClassImp(AliHLTHOMERReader);
fConnectionStatus = ENOMEM;
return;
}
- //fConnectionStatus = AddDataSource( shmKey, shmSize, fDataSources[0] );
+ fConnectionStatus = AddDataSource(const_cast<void*>(pBuffer), size, fDataSources[0] );
if ( fConnectionStatus )
fErrorConnection = 0;
else
{
fDataSourceCnt++;
- fShmDataSourceCnt++;
fDataSources[0].fNdx = 0;
}
}
fDataSources = new DataSource[ sourceCnt ];
if ( !fDataSources )
return false;
+ memset(fDataSources, 0, sizeof(DataSource)*sourceCnt);
fDataSourceCnt = 0;
fDataSourceMaxCnt = sourceCnt;
return true;
// a buffer data source is like a shm source apart from the shm attach and detach
// procedure. Furthermore, the size indicator at the beginning of the buffer is not
// cleared right before sources are read but after the reading.
- int ret;
+ //int ret;
if ( !pBuffer || size<=0) return EINVAL;
char* tmpchar = new char[ MAXHOSTNAMELEN+1 ];
return ENXIO;
// Clean up currently active event.
ReleaseCurrentEvent();
- int ret;
+ int ret=0;
// Trigger all configured data sources
for ( unsigned n = 0; n<fDataSourceCnt; n++ )
{
//Check to see that all sources contributed data for the same event
homer_uint64 eventID;
homer_uint64 eventType;
+ if (!fDataSources[0].fData)
+ {
+ fErrorConnection = 0;
+ fConnectionStatus=56;//ENOBUF;
+ return fConnectionStatus;
+ }
eventID = GetSourceEventID( fDataSources[0] );
eventType = GetSourceEventType( fDataSources[0] );
for ( unsigned n = 1; n < fDataSourceCnt; n++ )
{
- if ( GetSourceEventID( fDataSources[n] ) != eventID || GetSourceEventType( fDataSources[n] ) != eventType )
+ if ( !fDataSources[n].fData || GetSourceEventID( fDataSources[n] ) != eventID || GetSourceEventType( fDataSources[n] ) != eventType )
{
fErrorConnection = n;
fConnectionStatus=56;//EBADRQC;
{
if ( fDataSources[n].fType == kTCP )
delete [] (homer_uint8*)fDataSources[n].fData;
- fDataSources[n].fData = NULL;
+ // do not reset the data pointer for kBuf sources since this
+ // can not be set again.
+ if ( fDataSources[n].fType != kBuf )
+ fDataSources[n].fData = NULL;
}
fDataSources[n].fDataSize = fDataSources[n].fDataRead = 0;
}
return 0;
}
-int AliHLTHOMERReader::TriggerShmSource( DataSource& source, bool, unsigned long )
+int AliHLTHOMERReader::TriggerShmSource( DataSource& source, bool, unsigned long ) const
{
// see header file for class documentation
// clear the size indicator in the first 4 bytes of the buffer to request data
((source & 0xFF000000UL) >> 24);
}
-AliHLTHOMERReader* AliHLTHOMERReaderCreate(const void* pBuffer, int size)
+AliHLTHOMERReader* AliHLTHOMERReaderCreateFromTCPPort(const char* hostname, unsigned short port )
+ {
+ // see header file for function documentation
+ return new AliHLTHOMERReader(hostname, port);
+ }
+
+AliHLTHOMERReader* AliHLTHOMERReaderCreateFromTCPPorts(unsigned int tcpCnt, const char** hostnames, unsigned short* ports)
+ {
+ // see header file for function documentation
+ return new AliHLTHOMERReader(tcpCnt, hostnames, ports);
+ }
+
+AliHLTHOMERReader* AliHLTHOMERReaderCreateFromBuffer(const void* pBuffer, int size)
{
-// see header file for function documentation
+ // see header file for function documentation
return new AliHLTHOMERReader(pBuffer, size);
}
void AliHLTHOMERReaderDelete(AliHLTHOMERReader* pInstance)
{
-// see header file for function documentation
+ // see header file for function documentation
if (pInstance) delete pInstance;
}