|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #include "GaudiKernel/ServiceHandle.h"
6 #include "GaudiKernel/StateMachine.h"
7 #include "GaudiKernel/IAppMgrUI.h"
8 #include "GaudiKernel/GaudiHandle.h"
18 std::string fmterror(
int code) {
20 return std::string(strerror_r(
code, buf,
sizeof(buf)));
37 int retVal = pthread_mutex_init(&m_accessLock,NULL);
39 ATH_MSG_ERROR(
"Unable to initialize access lock while starting server: " << fmterror(retVal) );
40 return StatusCode::FAILURE;
55 return StatusCode::FAILURE;
58 return StatusCode::SUCCESS;
81 ATH_MSG_ERROR(
"Unable to create shutdown client for local server" );
82 return StatusCode::FAILURE;
92 # pragma GCC diagnostic push
93 # pragma GCC diagnostic ignored "-Wcast-function-type"
97 clnt_call(
client, NULLPROC, (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_void, NULL,
timeout);
99 # pragma GCC diagnostic pop
105 ATH_MSG_INFO(
"Waiting for server thread to terminate ..." );
112 unsigned long NRequests = *(
unsigned long*)ret;
113 ATH_MSG_DEBUG(
"Server thread stopped after handling " << NRequests <<
" requests" );
118 int retVal = pthread_mutex_destroy(&m_accessLock);
120 ATH_MSG_ERROR(
"Unable to destroy access lock after stopping server: " << fmterror(retVal) );
121 return StatusCode::FAILURE;
124 return StatusCode::SUCCESS;
134 ATH_MSG_ERROR(
"Server thread stopped while run-server-flag is set!" );
145 const std::string& mesg)
const
159 return msg().level();
173 return (
int)FSMState();
185 int retVal = pthread_mutex_lock(&m_accessLock);
187 ATH_MSG_ERROR(
"Unable to obtain access lock to get stream names: " << fmterror(retVal) );
203 retVal = pthread_mutex_unlock(&m_accessLock);
205 ATH_MSG_ERROR(
"Unable to release access lock after getting stream names: " << fmterror(retVal) );
217 int retVal = pthread_mutex_lock(&m_accessLock);
219 ATH_MSG_ERROR(
"Unable to obtain access lock to get stream ID: " << fmterror(retVal) );
227 retVal = pthread_mutex_unlock(&m_accessLock);
229 ATH_MSG_ERROR(
"Unable to release access lock after getting stream ID: " << fmterror(retVal) );
235 return (*MapItr).first;
244 int retVal = pthread_mutex_lock(&m_accessLock);
246 ATH_MSG_ERROR(
"Unable to obtain access lock to get event: " << fmterror(retVal) );
247 return std::string(
"");
254 retVal = pthread_mutex_unlock(&m_accessLock);
256 ATH_MSG_ERROR(
"Unable to release access lock after getting stream event: " << fmterror(retVal) );
262 return std::string((*MapItr).second);
269 base_class(
name, sl )
272 declareProperty(
"PortNumber",
m_portNumber=0,
"Port number to bind - assigned dynamically if set to zero [default: 0]");
307 return StatusCode::SUCCESS;
332 ATH_MSG_ERROR(
"Server thread is not running - refusing to update event" );
333 return StatusCode::FAILURE;
338 ATH_MSG_ERROR(
"Invalid event stream identifier - cannot add event" );
339 return StatusCode::FAILURE;
345 return StatusCode::FAILURE;
351 return StatusCode::FAILURE;
359 struct timespec
timeout = { 5, 0 };
362 int retVal = pthread_mutex_timedlock(&m_accessLock, &
timeout);
364 int retVal = pthread_mutex_lock(&m_accessLock);
367 ATH_MSG_ERROR(
"Unable to obtain access lock to update event: " << fmterror(retVal) );
368 return StatusCode::FAILURE;
389 <<
": " <<
e.what() );
391 pthread_mutex_unlock(&m_accessLock);
393 return StatusCode::FAILURE;
397 retVal = pthread_mutex_unlock(&m_accessLock);
399 ATH_MSG_ERROR(
"Unable to release access lock after updating event: " << fmterror(retVal) );
400 return StatusCode::FAILURE;
405 <<
" from run Nr. " << evtStreamID.
RunNumber() );
407 return StatusCode::SUCCESS;
JetConstituentVector::iterator iterator
pthread_t m_ServerThreadHandle
virtual const std::string GetEvent(const EventStreamID &evtStreamID) const override
get the current event for a particular stream
unsigned long EventNumber() const
struct ServerThreadArguments_t ServerThreadArguments
Arguments handed over fromt the main (Athena) thread to the server thread.
#define ATH_MSG_VERBOSE(x)
virtual void ServerThreadStopped() override
Callback when server thread terminates.
void * ONCRPCServerThread(void *args)
This is the actual server thread, which takes above arguments.
virtual std::vector< std::string > GetStreamNames() const override
get the names of all the streams
ONCRPCServerSvc(const std::string &name, ISvcLocator *sl)
Default constructor.
POOL::TEvent event(POOL::TEvent::kClassAccess)
::StatusCode StatusCode
StatusCode definition for legacy code.
virtual StatusCode finalize() override
Finalize - called once at the end.
StatusCode StartServer()
Start the server thread.
std::pair< const EventStreamID, const std::string > EventStreamPair
A map that stores events according to their EventStreamID Due to the way EventStreamID is build,...
const unsigned int NBYTESMAX
For the client-server communication, each event is uniquely identified by the run number,...
const std::string & StreamName() const
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
virtual int GetState() const override
get the Status of the application
virtual void Message(const MSG::Level level, const std::string &mesg) const override
This function is exposed to allow using athena messaging service from other threads.
EventStreamMap m_eventStreamMap
virtual StatusCode initialize() override
Gaudi default methods.
StatusCode StopServer()
Stop the server thread.
virtual ~ONCRPCServerSvc()
Destructor.
#define ATH_MSG_WARNING(x)
virtual const EventStreamID GetEventStreamID(const std::string &streamName) const override
get the current EventStreamID for a particular stream
virtual StatusCode UpdateEventForStream(const EventStreamID &evtStreamID, const std::string &event) override
Put this event as new current event for stream given by name.
virtual MSG::Level LogLevel() const override
Get the logging level.
unsigned int RunNumber() const
const unsigned int NSTREAMMAX