mirror of
https://github.com/RetroShare/RetroShare.git
synced 2026-09-12 19:50:17 +05:00
feedreader: drop the shutdown restart and the debug traces
The JSON API restart in stop() cost a RESTART_BURST_PROTECTION wait (7s) on every exit and brought the HTTP server back up in the middle of the core teardown, republishing resources whose backing services were about to stop. It was not gratuitous: it made "delete mJsonApiProvider" safe, because the running restbed service holds the resources this provider returned and their handlers capture it. libretroshare now stops the JSON API at the top of rsGlobalShutDown(), before stopPlugins(), so the resources are already gone by the time stop() runs and the provider can be deleted directly. Without that companion change this commit would turn a slow shutdown into a use-after-free, so the two go together. Also replace the five std::cerr traces with one RsDbg line on success and an RsInfo when the JSON API is not available, matching how the rest of the tree reports.
This commit is contained in:
parent
59116bee9a
commit
774cfda33c
@ -32,6 +32,7 @@
|
||||
#include "services/p3FeedReader.h"
|
||||
#include "services/FeedReaderJsonApi.h"
|
||||
#include <retroshare/rsjsonapi.h>
|
||||
#include <util/rsdebug.h>
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxslt/xsltconfig.h>
|
||||
@ -94,8 +95,6 @@ FeedReaderPlugin::FeedReaderPlugin()
|
||||
void FeedReaderPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
|
||||
{
|
||||
mInterfaces = interfaces;
|
||||
std::cerr << "FeedReader: JSON API interface pointer="
|
||||
<< static_cast<void*>(mInterfaces.mJsonApi) << std::endl;
|
||||
|
||||
mFeedReader = new p3FeedReader(mPlugInHandler, mInterfaces.mGxsForums, mInterfaces.mPosted);
|
||||
rsFeedReader = mFeedReader;
|
||||
@ -107,15 +106,14 @@ void FeedReaderPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
|
||||
{
|
||||
mJsonApiProvider = new FeedReaderJsonApi(*mFeedReader, *mInterfaces.mJsonApi);
|
||||
mInterfaces.mJsonApi->registerResourceProvider(*mJsonApiProvider);
|
||||
std::cerr << "FeedReader: JSON API provider registered="
|
||||
<< mInterfaces.mJsonApi->hasResourceProvider(*mJsonApiProvider)
|
||||
<< std::endl;
|
||||
// The core publishes all providers together after plugin initialization.
|
||||
// This avoids one burst-protected JSON API restart per plugin.
|
||||
|
||||
// No restart here: the core publishes every provider together once all
|
||||
// plugins have received their interfaces, which avoids one
|
||||
// burst-protected JSON API restart per plugin.
|
||||
RsDbg() << "FeedReader: JSON API routes registered.";
|
||||
}
|
||||
else
|
||||
std::cerr << "FeedReader: JSON API unavailable; routes not registered"
|
||||
<< std::endl;
|
||||
RsInfo() << "FeedReader: JSON API not available, routes not registered.";
|
||||
}
|
||||
|
||||
ConfigPage *FeedReaderPlugin::qt_config_page() const
|
||||
@ -145,11 +143,13 @@ void FeedReaderPlugin::stop()
|
||||
if(mJsonApiProvider)
|
||||
{
|
||||
if(mInterfaces.mJsonApi)
|
||||
{
|
||||
mInterfaces.mJsonApi->unregisterResourceProvider(*mJsonApiProvider);
|
||||
if(mInterfaces.mJsonApi->isRunning())
|
||||
mInterfaces.mJsonApi->restart(true);
|
||||
}
|
||||
|
||||
/* No restart here. The core stops the JSON API before it stops the
|
||||
* plugins, so the restbed resources whose handlers capture this
|
||||
* provider are already gone by now and deleting it is safe. Restarting
|
||||
* would only wait out RESTART_BURST_PROTECTION and bring the server
|
||||
* back up in the middle of the core teardown. */
|
||||
delete mJsonApiProvider;
|
||||
mJsonApiProvider = NULL;
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
|
||||
#include "FeedReaderJsonApi.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
@ -179,7 +178,6 @@ FeedReaderJsonApi::FeedReaderJsonApi(
|
||||
|
||||
std::vector<std::shared_ptr<restbed::Resource>> FeedReaderJsonApi::getResources() const
|
||||
{
|
||||
std::cerr << "FeedReader: constructing JSON API resources" << std::endl;
|
||||
std::vector<std::shared_ptr<restbed::Resource>> resources;
|
||||
auto resource = [this](const std::string& path, auto handler)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user