Skip to content
Snippets Groups Projects
Commit 6b8c792c authored by Michael Davis's avatar Michael Davis
Browse files

[EOS-CTA] Removes ServiceClientSide::Shutdown()

The implementation of Stop() is simply { return false; } so this
function is superfluous. It's not possible to shut down the service
on the client side except when completely closing down the client.
parent e5589cfa
Branches
Tags
No related merge requests found
......@@ -45,6 +45,22 @@ public:
#endif
}
/*!
* Stop the Service.
*
* Requires some method to pass Finished(true) to in-flight Requests. This has been raised with Andy.
* Currently not implemented as it would require tracking all in-flight Requests by the application
* when this is really the job of the framework.
*/
virtual bool Stop() override
{
#ifdef XRDSSI_DEBUG
std::cout << "[DEBUG] Service::Stop()" << std::endl;
#endif
return false;
}
virtual void ProcessRequest(XrdSsiRequest &reqRef, XrdSsiResource &resRef) override;
/*
......
......@@ -19,8 +19,6 @@
#ifndef __XRD_SSI_PB_SERVICE_CLIENT_SIDE_H
#define __XRD_SSI_PB_SERVICE_CLIENT_SIDE_H
#include <unistd.h> // sleep()
#include <XrdSsi/XrdSsiProvider.hh>
#include <XrdSsi/XrdSsiService.hh>
#include "XrdSsiPbException.hpp"
......@@ -42,7 +40,6 @@ namespace XrdSsiPb {
const unsigned int DefaultResponseBufferSize = 2097152; //!< Default size for the response buffer in bytes = 2 Mb
const unsigned int DefaultServerTimeout = 15; //!< Maximum XRootD reply timeout in secs
const unsigned int DefaultShutdownTimeout = 0; //!< Maximum time to wait for the Service to shut down in secs
......@@ -62,12 +59,9 @@ public:
virtual ~ServiceClientSide();
bool Shutdown(int shutdown_tmo = DefaultShutdownTimeout);
MetadataType Send(const RequestType &request);
private:
bool m_is_running; //!< Is the service running?
XrdSsiResource m_resource; //!< Requests are bound to this resource. As the resource is
//!< reusable, the lifetime of the resource is the same as the
//!< lifetime of the Service object.
......@@ -91,7 +85,6 @@ ServiceClientSide<RequestType, MetadataType, AlertType>::
ServiceClientSide(const std::string &hostname, unsigned int port, const std::string &resource,
unsigned int response_bufsize,
unsigned int server_tmo) :
m_is_running(false),
m_resource(resource),
m_response_bufsize(response_bufsize),
m_server_tmo(server_tmo)
......@@ -126,8 +119,6 @@ ServiceClientSide(const std::string &hostname, unsigned int port, const std::str
{
throw XrdSsiException(eInfo);
}
m_is_running = true;
}
......@@ -141,82 +132,16 @@ ServiceClientSide<RequestType, MetadataType, AlertType>::~ServiceClientSide()
{
#ifdef XRDSSI_DEBUG
std::cout << "[DEBUG] ServiceClientSide() destructor" << std::endl;
#endif
#if 0
// Default Stop() implementation is return false;
// i.e. XRootD SSI makes no attempt to shut down!
// If the Service has not been shut down, make one last valiant effort to do so
if(m_is_running && !m_server_ptr->Stop())
{
std::cerr << "ServiceClientSide object was destroyed before all Requests have been processed. "
<< "This will cause a memory leak. Call Shutdown() before deleting the object." << std::endl;
}
#endif
}
/*!
* Request Shutdown of the Service
*
* TODO: Define a Stop() method for the Service. Currently this method will always fail.
*
* A Service object can only be deleted after all requests handed to the object have completed. It is
* possible to take back control of Requests by calling each Request's Finished() method: this cancels
* the Request and the object can then be deleted.
*
* However, the current interface does not provide a way to recover a list of outstanding XrdSsi
* Requests. I have raised this with Andy.
*
* @param[in] shutdown_tmo No. of seconds to wait before giving up
*
* @retval true The Service has been shut down
* @retval false The Service has not been shut down
*/
template <typename RequestType, typename MetadataType, typename AlertType>
bool ServiceClientSide<RequestType, MetadataType, AlertType>::
Shutdown(int shutdown_tmo)
{
// Trivial case: server has already been shut down
if(!m_is_running) return true;
#ifdef XRDSSI_DEBUG
std::cerr << "[DEBUG] ServiceClientSide::Shutdown():" << std::endl;
std::cerr << "Shutting down XRootD SSI service...";
#endif
// The XrdSsiService object cannot be explicitly deleted. The Stop() method deletes the object if
// it is safe to do so.
while(!m_server_ptr->Stop() && shutdown_tmo--)
{
sleep(1);
#ifdef XRDSSI_DEBUG
std::cerr << ".";
#endif
}
if(shutdown_tmo > 0)
if(!m_server_ptr->Stop())
{
m_is_running = false;
// As there is no way to get a list of in-flight Requests from the Service, the current Stop()
// implementation simply returns false. i.e. there is no way to know if we are shutting down
// cleanly or not.
#ifdef XRDSSI_DEBUG
std::cerr << "done." << std::endl;
#endif
std::cout << "[WARNING] ServiceClientSide object was destroyed before shutting down the Service." << std::endl;
}
else
{
#ifdef XRDSSI_DEBUG
std::cerr << "failed." << std::endl;
#endif
}
return !m_is_running;
}
......@@ -228,13 +153,6 @@ Shutdown(int shutdown_tmo)
template <typename RequestType, typename MetadataType, typename AlertType>
MetadataType ServiceClientSide<RequestType, MetadataType, AlertType>::Send(const RequestType &request)
{
// Check service is up
if(!m_is_running)
{
throw XrdSsiException("Service has been stopped");
}
// Serialize the Request
if(!request.SerializeToString(&m_request_str))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment