THREAD_LOCAL ProfileStats appid_perf_stats;
THREAD_LOCAL AppIdStats appid_stats;
+THREAD_LOCAL bool ThirdPartyAppIdContext::tp_reload_in_progress = false;
static const Parameter s_params[] =
{
{
public:
bool execute(Analyzer&, void**) override;
- ACThirdPartyAppIdContextSwap(ThirdPartyAppIdContext* tp_ctxt, Request& current_request,
- bool from_shell): tp_ctxt(tp_ctxt),request(current_request),
- from_shell(from_shell) { }
+ ACThirdPartyAppIdContextSwap(const AppIdInspector& inspector, ThirdPartyAppIdContext* tp_ctxt,
+ Request& current_request, bool from_shell): inspector(inspector),
+ tp_ctxt(tp_ctxt),request(current_request), from_shell(from_shell) { }
~ACThirdPartyAppIdContextSwap() override;
const char* stringify() override { return "THIRD-PARTY_CONTEXT_SWAP"; }
private:
+ const AppIdInspector& inspector;
ThirdPartyAppIdContext* tp_ctxt = nullptr;
Request& request;
bool from_shell;
bool ACThirdPartyAppIdContextSwap::execute(Analyzer&, void**)
{
assert(tp_appid_thread_ctxt);
- AppIdInspector* inspector = (AppIdInspector*) InspectorManager::get_inspector(MOD_NAME);
- assert(inspector);
- ThirdPartyAppIdContext* tp_appid_ctxt = inspector->get_ctxt().get_tp_appid_ctxt();
+ ThirdPartyAppIdContext* tp_appid_ctxt = inspector.get_ctxt().get_tp_appid_ctxt();
assert(tp_appid_thread_ctxt != tp_appid_ctxt);
+ bool reload_in_progress = tp_appid_thread_ctxt->tfini(true);
+ tp_appid_thread_ctxt->set_tp_reload_in_progress(reload_in_progress);
+ if (reload_in_progress)
+ return false;
request.respond("== swapping third-party configuration\n", from_shell);
- tp_appid_thread_ctxt->tfini();
tp_appid_ctxt->tinit();
tp_appid_thread_ctxt = tp_appid_ctxt;
current_request.respond("== reload pending; retry\n", from_shell);
return 0;
}
- Swapper::set_reload_in_progress(true);
current_request.respond(".. reloading third-party\n", from_shell);
AppIdInspector* inspector = (AppIdInspector*) InspectorManager::get_inspector(MOD_NAME);
if (!inspector)
current_request.respond("== reload third-party failed - third-party module doesn't exist\n", from_shell);
return 0;
}
+ Swapper::set_reload_in_progress(true);
ctxt.create_tp_appid_ctxt();
- main_broadcast_command(new ACThirdPartyAppIdContextSwap(old_ctxt, current_request, from_shell), from_shell);
+ main_broadcast_command(new ACThirdPartyAppIdContextSwap(*inspector, old_ctxt,
+ current_request, from_shell), from_shell);
return 0;
}
#include <vector>
#include <string>
+#include "main/thread.h"
#include "tp_appid_types.h"
#define THIRD_PARTY_APPID_API_VERSION 5
const std::string& module_name() const { return name; }
virtual int tinit() = 0;
- virtual int tfini() = 0;
+ virtual bool tfini(bool reload = false) = 0;
virtual const ThirdPartyConfig& get_config() const { return cfg; }
+ void set_tp_reload_in_progress(bool value) { tp_reload_in_progress = value; }
+ bool get_tp_reload_in_progress() { return tp_reload_in_progress; }
+
protected:
const uint32_t version;
const std::string name;
// No implicit constructor as derived classes need to provide
// version and name.
ThirdPartyAppIdContext() : version(0), name("") { }
+ static THREAD_LOCAL bool tp_reload_in_progress;
};
#endif