27 if (RetVal == 0)
return true ;
30 std::ostringstream
msg;
32 msg <<
"Error in " << Module <<
": " << strerror_r(RetVal, errbuf,
sizeof(errbuf));
48# pragma GCC diagnostic push
49# pragma GCC diagnostic ignored "-Wcast-function-type"
51#if defined(__clang__) && __clang_major__ >= 19
52# pragma clang diagnostic push
53# pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
55 if (!svc_sendreply(transp, (xdrproc_t)xdr_void, 0))
57 checkResult(errno,
"dispatch thread sending reply to NULLPROC call",ServerSvc);
59#if defined(__clang__) && __clang_major__ >= 19
60# pragma clang diagnostic pop
63# pragma GCC diagnostic pop
72 if (!svc_sendreply(transp, (xdrproc_t)xdr_int, (caddr_t)&state))
74 checkResult(errno,
"dispatch thread sending reply to GETSTATUS call",ServerSvc);
83 std::vector<std::string> StreamNames = ServerSvc->
GetStreamNames();
89 XDRStreams.
NStreams = StreamNames.size();
92 XDRStreams.
StreamNames = (
char**) malloc(StreamNames.size()*
sizeof(
char*));
95 for (
unsigned int iName = 0; iName < StreamNames.size(); ++iName)
96 XDRStreams.
StreamNames[iName] = strdup(StreamNames[iName].c_str());
99 if (!svc_sendreply(transp, (xdrproc_t)
xdr_streams, (caddr_t)&XDRStreams))
100 checkResult(errno,
"dispatch thread sending reply to GETSTREAMS call",ServerSvc);
103 xdr_free((xdrproc_t)
xdr_streams,(caddr_t)&XDRStreams);
115 std::ostringstream
msg;
117 msg <<
"Request to return event with void event request structure";
119 svcerr_systemerr(transp);
125 <<
" with existing event " << eventReq->
EventNumber
142 event.isAvailable = false ;
143 event.isIdentical = false ;
144 event.isCompressed = false ;
146 event.RunNumber = currEvtStreamID.
RunNumber();
148 event.NBytes = 0;
event.EventData = NULL ;
151 if (!currEvtStreamID.
isValid()) {
153 msg <<
"Sending response NO SUCH STREAM "; ServerSvc->
Message(MSG::DEBUG,
msg.str());
154 if (!svc_sendreply(transp, (xdrproc_t)
xdr_event, (caddr_t)&event))
155 checkResult(errno,
"dispatch thread sending reply to GETEVENT call",ServerSvc);
159 event.isAvailable = true ;
162 if ( currEvtStreamID.
isSameEvent(reqEvtStreamID) ){
164 event.isIdentical = true ;
166 msg <<
"Sending response SAME EVENT "; ServerSvc->
Message(MSG::DEBUG,
msg.str());
167 if (!svc_sendreply(transp, (xdrproc_t)
xdr_event, (caddr_t)&event))
168 checkResult(errno,
"dispatch thread sending reply to GETEVENT call",ServerSvc);
173 std::string evt = ServerSvc->
GetEvent( currEvtStreamID );
174 event.EventData = evt.c_str();
175 event.NBytes = strlen(evt.c_str())+1;
177 msg <<
"Sending response NEW EVENT (" <<
event.EventNumber <<
","<<
event.RunNumber <<
")" ;
179 if (!svc_sendreply(transp, (xdrproc_t)
xdr_event, (caddr_t)&event))
180 checkResult(errno,
"dispatch thread sending reply to GETEVENT call",ServerSvc);
193 std::ostringstream
msg;
194 if ( (!event) || (event->EventNumber<0) || (!event->RunNumber) || (!event->StreamName) ) {
195 msg <<
"Request to set new event with void or invalid event structure";
197 svcerr_systemerr(transp);
202 msg <<
"Request to set new event " <<
event->EventNumber
203 <<
" from run " <<
event->RunNumber
204 <<
" for stream " <<
event->StreamName;
210 bool_t isSuccess=
false;
213 EventStreamID newEvtStreamID(event->EventNumber,event->RunNumber,event->StreamName);
216 if (! newEvtStreamID.
isValid()) {
217 msg <<
"Request to set new event with invalid stream name or event/run number";
219 if (!svc_sendreply(transp, (xdrproc_t)xdr_bool, (caddr_t)&isSuccess))
220 checkResult(errno,
"dispatch thread sending reply to SETEVENT call",ServerSvc);
225 if ((! event->EventData ) || (strlen(event->EventData) == 0)){
226 msg <<
"Request to set new event with invalid event data";
228 if (!svc_sendreply(transp, (xdrproc_t)xdr_bool, (caddr_t)&isSuccess))
229 checkResult(errno,
"dispatch thread sending reply to SETEVENT call",ServerSvc);
234 if ( strlen(event->EventData) != event->NBytes -1 ){
235 msg <<
"Event string length does not match claimed number of bytes (null-termination problem?)";
237 if (!svc_sendreply(transp, (xdrproc_t)xdr_bool, (caddr_t)&isSuccess))
238 checkResult(errno,
"dispatch thread sending reply to SETEVENT call",ServerSvc);
242 std::string EvtData(event->EventData);
250 msg <<
"Sending response for set new event: ";
251 if (isSuccess)
msg <<
" SUCCESS!";
else msg <<
" FAILED!";
254 if (!svc_sendreply(transp, (xdrproc_t)xdr_bool, (caddr_t)&isSuccess))
255 checkResult(errno,
"dispatch thread sending reply to SETEVENT call",ServerSvc);
Define macros for attributes used to control the static checker.
For the client-server communication, each event is uniquely identified by the run number,...
bool isSameEvent(const EventStreamID &id) const
unsigned int RunNumber() const
unsigned long EventNumber() const
const char * StreamNameCStr() const
virtual StatusCode UpdateEventForStream(const EventStreamID &, const std::string &)=0
Put this event as new current event for stream given by name.
virtual const EventStreamID GetEventStreamID(const std::string &streamName) const =0
get the current EventStreamID for a particular stream
virtual std::vector< std::string > GetStreamNames() const =0
get the names of all the streams
virtual int GetState() const =0
get the Status of the application
virtual const std::string GetEvent(const EventStreamID &evtStreamID) const =0
get the current event for a particular stream
Pure abstract interface to provide some athena-indepandant messaging Note that only MSG::Level enum i...
virtual void Message(const MSG::Level level, const std::string &msg) const =0
Pure abstract interface for all full server implementations.
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
void ReturnState(SVCXPRT *transp, IServer *const ServerSvc)
Implementation of ONCRPC_ATHENASTATUS_PROC Return the current athena status in XDR representation.
bool_t xdr_event_req(XDR *xdrsp, EventRequest *eventReq)
De-/Encoding of EventRequest_t.
void ReturnEvent(SVCXPRT *transp, const EventRequest *eventReq, IServer *const ServerSvc)
Implementation of ONCRPC_GETEVENT_PROC Return an event from a certain streams.
void ReturnStreams(SVCXPRT *transp, IServer *const ServerSvc)
Implementation of ONCRPC_GETSTREAMS_PROC Return the currently available event streams.
bool checkResult(const int RetVal, const std::string &Module, IMessage *const ServerSvc)
Simple result checking routine, that will output an errorMsg throught the ServerSvc if there was an e...
struct EventRequest_t EventRequest
Data structures for GetEvent functions.
void SetNewEvent(SVCXPRT *transp, const Event *event, IServer *const ServerSvc)
Implementation of ONCRPC_SETEVENT_PROC Set a new event for a certain streams.
void ReturnNull(SVCXPRT *transp, IServer *const ServerSvc)
Implementation of NULLPROC Return nothing - server has just been pinged.
bool_t xdr_streams(XDR *xdrsp, Streams *streams)
De- and Encoding of Streams_t.
struct Streams_t Streams
Data structures for GetStreams functions.
pthread_key_t ServerSvcKey ATLAS_THREAD_SAFE
bool_t xdr_event(XDR *xdrsp, Event *event)
De-/Encoding of Event_t.