From 774cfda33c42f52d172f102a4936b0c816036721 Mon Sep 17 00:00:00 2001 From: jolavillette Date: Tue, 11 Aug 2026 22:56:47 +0200 Subject: [PATCH] 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. --- plugins/FeedReader/FeedReaderPlugin.cpp | 26 +++++++++---------- .../FeedReader/services/FeedReaderJsonApi.cpp | 2 -- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/plugins/FeedReader/FeedReaderPlugin.cpp b/plugins/FeedReader/FeedReaderPlugin.cpp index b36a3a5bb..ef1097366 100644 --- a/plugins/FeedReader/FeedReaderPlugin.cpp +++ b/plugins/FeedReader/FeedReaderPlugin.cpp @@ -32,6 +32,7 @@ #include "services/p3FeedReader.h" #include "services/FeedReaderJsonApi.h" #include +#include #include #include @@ -94,8 +95,6 @@ FeedReaderPlugin::FeedReaderPlugin() void FeedReaderPlugin::setInterfaces(RsPlugInInterfaces &interfaces) { mInterfaces = interfaces; - std::cerr << "FeedReader: JSON API interface pointer=" - << static_cast(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; } diff --git a/plugins/FeedReader/services/FeedReaderJsonApi.cpp b/plugins/FeedReader/services/FeedReaderJsonApi.cpp index bcd55f8d1..82951c707 100644 --- a/plugins/FeedReader/services/FeedReaderJsonApi.cpp +++ b/plugins/FeedReader/services/FeedReaderJsonApi.cpp @@ -20,7 +20,6 @@ #include "FeedReaderJsonApi.h" -#include #include #include @@ -179,7 +178,6 @@ FeedReaderJsonApi::FeedReaderJsonApi( std::vector> FeedReaderJsonApi::getResources() const { - std::cerr << "FeedReader: constructing JSON API resources" << std::endl; std::vector> resources; auto resource = [this](const std::string& path, auto handler) {