diff --git a/frontend/XrdSsiPbRequest.h b/frontend/XrdSsiPbRequest.h index de6ef09df7cba463598baa9970773f872f313a6e..d108cf2555429899c844a706e1964fcaf1ac637f 100644 --- a/frontend/XrdSsiPbRequest.h +++ b/frontend/XrdSsiPbRequest.h @@ -142,33 +142,30 @@ bool XrdSsiPbRequest<RequestType, ResponseType, MetadataType, AlertType>::Proces { // Deserialize the metadata - const std::string metadata_str(metadata_buffer, metadata_len); - MetadataType metadata; - if(!metadata.ParseFromString(metadata_str)) + if(metadata.ParseFromArray(metadata_buffer, metadata_len)) { - ErrorCallback("metadata.ParseFromString() failed"); - Finished(); - delete this; - break; + MetadataCallback(metadata); } - - MetadataCallback(metadata); - - // If this is a metadata-only response, there is nothing more to do - - if(rInfo.rType == XrdSsiRespInfo::isNone) + else { + ErrorCallback("metadata.ParseFromArray() failed"); Finished(); delete this; break; } } - // Handle response messages + // If this is a metadata-only response, there is nothing more to do - if(rInfo.rType == XrdSsiRespInfo::isData) + if(rInfo.rType == XrdSsiRespInfo::isNone) + { + Finished(); + delete this; + break; + } + else // XrdSsiRespInfo::isData { // Allocate response buffer @@ -197,17 +194,15 @@ XrdSsiRequest::PRD_Xeq XrdSsiPbRequest<RequestType, ResponseType, MetadataType, // Deserialize the response - const std::string response_str(response_bufptr, response_buflen); - ResponseType response; - if(response.ParseFromString(response_str)) + if(response.ParseFromArray(response_bufptr, response_buflen)) { ResponseCallback(response); } else { - ErrorCallback("response.ParseFromString() failed"); + ErrorCallback("response.ParseFromArray() failed"); } } @@ -247,17 +242,15 @@ void XrdSsiPbRequest<RequestType, ResponseType, MetadataType, AlertType>::Alert( // Deserialize the Alert - const std::string alert_str(alert_buffer, alert_len); - AlertType alert; - if(alert.ParseFromString(alert_str)) + if(alert.ParseFromArray(alert_buffer, alert_len)) { AlertCallback(alert); } else { - ErrorCallback("alert.ParseFromString() failed"); + ErrorCallback("alert.ParseFromArray() failed"); } // Recycle the message to free memory diff --git a/frontend/XrdSsiPbRequestProc.h b/frontend/XrdSsiPbRequestProc.h index 2f6b32131cd15b53ed2a1dee9f1c40e4ac6839bb..a2b245002ca70e005226c11e8f4031501566180b 100644 --- a/frontend/XrdSsiPbRequestProc.h +++ b/frontend/XrdSsiPbRequestProc.h @@ -61,27 +61,19 @@ private: template <typename RequestType, typename ResponseType, typename MetadataType, typename AlertType> void RequestProc<RequestType, ResponseType, MetadataType, AlertType>::Execute() { - using namespace std; + std::cerr << "Execute()" << std::endl; - cerr << "Execute()" << endl; - - // Unpack the Request buffer into a string object. - // - // We need to construct this with an explicit length, as request_buffer is a binary buffer, not a - // null-terminated string. + // Deserialize the Request int request_len; const char *request_buffer = GetRequest(request_len); - const std::string request_str(request_buffer, request_len); - // Deserialize the Request - - if(!m_request.ParseFromString(request_str)) + if(!m_request.ParseFromArray(request_buffer, request_len)) { - throw XrdSsiException("request.ParseFromString() failed"); + throw XrdSsiException("m_request.ParseFromArray() failed"); } - // Release the request buffer (optional, perhaps it is more efficient to reuse it?) + // Release the request buffer ReleaseRequestBuffer(); @@ -89,11 +81,11 @@ void RequestProc<RequestType, ResponseType, MetadataType, AlertType>::Execute() ExecuteAction(); - // Optional: send alerts + // Send alerts ExecuteAlerts(); - // Optional: prepare to send metadata ahead of the response + // Prepare to send metadata ahead of the response ExecuteMetadata(); @@ -133,9 +125,7 @@ void RequestProc<RequestType, ResponseType, MetadataType, AlertType>::Execute() template <typename RequestType, typename ResponseType, typename MetadataType, typename AlertType> void RequestProc<RequestType, ResponseType, MetadataType, AlertType>::Finished(XrdSsiRequest &rqstR, const XrdSsiRespInfo &rInfo, bool cancel) { - using namespace std; - - cerr << "Finished()" << endl; + std::cerr << "Finished()" << std::endl; // Reclaim any allocated resources }