mirror of
https://github.com/rehlds/metamod-r.git
synced 2025-03-03 17:15:26 +03:00
Make correct messages for delayed load/unload
This commit is contained in:
parent
06d78fe775
commit
895dea5eba
@ -364,11 +364,12 @@ void cmd_doplug(PLUG_CMD pcmd)
|
|||||||
case PC_UNLOAD:
|
case PC_UNLOAD:
|
||||||
{
|
{
|
||||||
findp->set_action(PA_UNLOAD);
|
findp->set_action(PA_UNLOAD);
|
||||||
if (findp->unload(PT_ANYTIME, PNL_COMMAND)) {
|
bool delayed;
|
||||||
|
if (findp->unload(PT_ANYTIME, PNL_COMMAND, delayed)) {
|
||||||
META_CONS("Unloaded plugin '%s'", findp->description());
|
META_CONS("Unloaded plugin '%s'", findp->description());
|
||||||
g_plugins->show();
|
g_plugins->show();
|
||||||
}
|
}
|
||||||
else if (false /*meta_errno == ME_DELAYED*/) // TODO
|
else if (delayed)
|
||||||
META_CONS("Unload delayed for plugin '%s'", findp->description());
|
META_CONS("Unload delayed for plugin '%s'", findp->description());
|
||||||
else
|
else
|
||||||
META_CONS("Unload failed for plugin '%s'", findp->description());
|
META_CONS("Unload failed for plugin '%s'", findp->description());
|
||||||
@ -377,7 +378,8 @@ void cmd_doplug(PLUG_CMD pcmd)
|
|||||||
case PC_FORCE_UNLOAD:
|
case PC_FORCE_UNLOAD:
|
||||||
{
|
{
|
||||||
findp->set_action(PA_UNLOAD);
|
findp->set_action(PA_UNLOAD);
|
||||||
if (findp->unload(PT_ANYTIME, PNL_CMD_FORCED)) {
|
bool delayed;
|
||||||
|
if (findp->unload(PT_ANYTIME, PNL_CMD_FORCED, delayed)) {
|
||||||
META_CONS("Forced unload plugin '%s'", findp->description());
|
META_CONS("Forced unload plugin '%s'", findp->description());
|
||||||
g_plugins->show();
|
g_plugins->show();
|
||||||
}
|
}
|
||||||
@ -388,12 +390,11 @@ void cmd_doplug(PLUG_CMD pcmd)
|
|||||||
case PC_RELOAD:
|
case PC_RELOAD:
|
||||||
{
|
{
|
||||||
findp->set_action(PA_RELOAD);
|
findp->set_action(PA_RELOAD);
|
||||||
if (findp->reload(PT_ANYTIME, PNL_COMMAND))
|
bool delayed;
|
||||||
|
if (findp->reload(PT_ANYTIME, PNL_COMMAND, delayed))
|
||||||
META_CONS("Reloaded plugin '%s'", findp->description());
|
META_CONS("Reloaded plugin '%s'", findp->description());
|
||||||
else if (0/*meta_errno == ME_DELAYED*/) // TODO
|
else if (delayed)
|
||||||
META_CONS("Reload delayed for plugin '%s'", findp->description());
|
META_CONS("Reload delayed for plugin '%s'", findp->description());
|
||||||
else if (0/*meta_errno == ME_NOTALLOWED*/)
|
|
||||||
META_CONS("Reload not allowed for plugin '%s' now, only allowed %s", findp->description(), findp->str_loadable(SL_ALLOWED));
|
|
||||||
else
|
else
|
||||||
META_CONS("Reload failed for plugin '%s'", findp->description());
|
META_CONS("Reload failed for plugin '%s'", findp->description());
|
||||||
break;
|
break;
|
||||||
|
@ -191,7 +191,8 @@ MPlugin* MPluginList::plugin_addload(plid_t plid, const char* fname, PLUG_LOADTI
|
|||||||
}
|
}
|
||||||
|
|
||||||
pl_added->m_action = PA_LOAD;
|
pl_added->m_action = PA_LOAD;
|
||||||
if (!pl_added->load(now)) {
|
bool delayed;
|
||||||
|
if (!pl_added->load(now, delayed)) {
|
||||||
if (pl_added->m_status == PL_OPENED) {
|
if (pl_added->m_status == PL_OPENED) {
|
||||||
META_DEBUG(1, "Opened plugin '%s', but failed to attach; see log", pl_added->m_desc);
|
META_DEBUG(1, "Opened plugin '%s', but failed to attach; see log", pl_added->m_desc);
|
||||||
}
|
}
|
||||||
@ -448,7 +449,8 @@ bool MPluginList::cmd_addload(const char* args)
|
|||||||
|
|
||||||
// try to load new plugin
|
// try to load new plugin
|
||||||
pl_added->m_action = PA_LOAD;
|
pl_added->m_action = PA_LOAD;
|
||||||
if (!pl_added->load(PT_ANYTIME)) {
|
bool delayed;
|
||||||
|
if (!pl_added->load(PT_ANYTIME, delayed)) {
|
||||||
// load failed
|
// load failed
|
||||||
if (pl_added->m_status == PL_OPENED)
|
if (pl_added->m_status == PL_OPENED)
|
||||||
META_CONS("Opened plugin '%s', but failed to attach; see log", pl_added->m_desc);
|
META_CONS("Opened plugin '%s', but failed to attach; see log", pl_added->m_desc);
|
||||||
@ -479,7 +481,8 @@ bool MPluginList::load()
|
|||||||
if (m_plist[i].m_status < PL_VALID)
|
if (m_plist[i].m_status < PL_VALID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (m_plist[i].load(PT_STARTUP))
|
bool delayed;
|
||||||
|
if (m_plist[i].load(PT_STARTUP, delayed))
|
||||||
n++;
|
n++;
|
||||||
else
|
else
|
||||||
// all plugins should be loadable at startup...
|
// all plugins should be loadable at startup...
|
||||||
@ -502,6 +505,7 @@ bool MPluginList::refresh(PLUG_LOADTIME now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
META_LOG("dll: Updating plugins...");
|
META_LOG("dll: Updating plugins...");
|
||||||
|
bool delayed;
|
||||||
for (int i = 0; i < m_max_loaded_count; i++) {
|
for (int i = 0; i < m_max_loaded_count; i++) {
|
||||||
auto iplug = &m_plist[i];
|
auto iplug = &m_plist[i];
|
||||||
if (iplug->m_status < PL_VALID)
|
if (iplug->m_status < PL_VALID)
|
||||||
@ -515,14 +519,14 @@ bool MPluginList::refresh(PLUG_LOADTIME now)
|
|||||||
break;
|
break;
|
||||||
case PA_LOAD:
|
case PA_LOAD:
|
||||||
META_DEBUG(1, "Loading plugin '%s'", iplug->m_desc);
|
META_DEBUG(1, "Loading plugin '%s'", iplug->m_desc);
|
||||||
if (iplug->load(now))
|
if (iplug->load(now, delayed))
|
||||||
nloaded++;
|
nloaded++;
|
||||||
/*else if (meta_errno == ME_DELAYED) TODO
|
/*else if (meta_errno == ME_DELAYED) TODO
|
||||||
ndelayed++;*/
|
ndelayed++;*/
|
||||||
break;
|
break;
|
||||||
case PA_RELOAD:
|
case PA_RELOAD:
|
||||||
META_DEBUG(1, "Reloading plugin '%s'", iplug->m_desc);
|
META_DEBUG(1, "Reloading plugin '%s'", iplug->m_desc);
|
||||||
if (iplug->reload(now, PNL_FILE_NEWER))
|
if (iplug->reload(now, PNL_FILE_NEWER, delayed))
|
||||||
nreloaded++;
|
nreloaded++;
|
||||||
/*else if (meta_errno == ME_DELAYED) TODO
|
/*else if (meta_errno == ME_DELAYED) TODO
|
||||||
ndelayed++;*/
|
ndelayed++;*/
|
||||||
@ -532,7 +536,7 @@ bool MPluginList::refresh(PLUG_LOADTIME now)
|
|||||||
if (iplug->m_source == PS_INI && iplug->m_status >= PL_RUNNING) {
|
if (iplug->m_source == PS_INI && iplug->m_status >= PL_RUNNING) {
|
||||||
META_DEBUG(1, "Unloading plugin '%s'", iplug->m_desc);
|
META_DEBUG(1, "Unloading plugin '%s'", iplug->m_desc);
|
||||||
iplug->m_action = PA_UNLOAD;
|
iplug->m_action = PA_UNLOAD;
|
||||||
if (iplug->unload(now, PNL_INI_DELETED))
|
if (iplug->unload(now, PNL_INI_DELETED, delayed))
|
||||||
nunloaded++;
|
nunloaded++;
|
||||||
/*else if (meta_errno == ME_DELAYED) TODO
|
/*else if (meta_errno == ME_DELAYED) TODO
|
||||||
ndelayed++;*/
|
ndelayed++;*/
|
||||||
|
@ -372,8 +372,9 @@ bool MPlugin::platform_match(MPlugin *other) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load a plugin; query, check allowed time, attach.
|
// Load a plugin; query, check allowed time, attach.
|
||||||
bool MPlugin::load(PLUG_LOADTIME now)
|
bool MPlugin::load(PLUG_LOADTIME now, bool& delayed)
|
||||||
{
|
{
|
||||||
|
delayed = false;
|
||||||
if (!check_input()) {
|
if (!check_input()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -405,6 +406,7 @@ bool MPlugin::load(PLUG_LOADTIME now)
|
|||||||
if (m_info->loadable > PT_STARTUP) {
|
if (m_info->loadable > PT_STARTUP) {
|
||||||
// will try to attach again at next opportunity
|
// will try to attach again at next opportunity
|
||||||
META_DEBUG(2, "dll: Delaying load plugin '%s'; can't attach now: allowed=%s; now=%s", m_desc, str_loadable(), str_loadtime(now, SL_SIMPLE));
|
META_DEBUG(2, "dll: Delaying load plugin '%s'; can't attach now: allowed=%s; now=%s", m_desc, str_loadable(), str_loadtime(now, SL_SIMPLE));
|
||||||
|
delayed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,8 +447,9 @@ bool MPlugin::load(PLUG_LOADTIME now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unload a plugin. Check time, detach.
|
// Unload a plugin. Check time, detach.
|
||||||
bool MPlugin::unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
bool MPlugin::unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason, bool& delayed)
|
||||||
{
|
{
|
||||||
|
delayed = false;
|
||||||
if (!check_input()) {
|
if (!check_input()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -472,6 +475,7 @@ bool MPlugin::unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
|||||||
META_DEBUG(2, "dll: Delaying unload plugin '%s'; can't detach now: allowed=%s; now=%s", m_desc, str_unloadable(), str_loadtime(now, SL_SIMPLE));
|
META_DEBUG(2, "dll: Delaying unload plugin '%s'; can't detach now: allowed=%s; now=%s", m_desc, str_unloadable(), str_loadtime(now, SL_SIMPLE));
|
||||||
// caller should give message to user
|
// caller should give message to user
|
||||||
// try to unload again at next opportunity
|
// try to unload again at next opportunity
|
||||||
|
delayed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,8 +538,9 @@ bool MPlugin::unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reload a plugin; unload and load again.
|
// Reload a plugin; unload and load again.
|
||||||
bool MPlugin::reload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
bool MPlugin::reload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason, bool& delayed)
|
||||||
{
|
{
|
||||||
|
delayed = false;
|
||||||
if (!check_input()) {
|
if (!check_input()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -560,12 +565,12 @@ bool MPlugin::reload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
|||||||
reason = PNL_RELOAD;
|
reason = PNL_RELOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!unload(now, reason)) {
|
if (!unload(now, reason, delayed)) {
|
||||||
META_WARNING("dll: Failed to unload plugin '%s' for reloading", m_desc);
|
META_WARNING("dll: Failed to unload plugin '%s' for reloading", m_desc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!load(now)) {
|
if (!load(now, delayed)) {
|
||||||
META_WARNING("dll: Failed to reload plugin '%s' after unloading", m_desc);
|
META_WARNING("dll: Failed to reload plugin '%s' after unloading", m_desc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -613,12 +618,13 @@ bool MPlugin::unpause()
|
|||||||
// Retry pending action, presumably from a previous failure.
|
// Retry pending action, presumably from a previous failure.
|
||||||
bool MPlugin::retry(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
bool MPlugin::retry(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
||||||
{
|
{
|
||||||
|
bool delayed;
|
||||||
if (m_action == PA_LOAD || m_action == PA_ATTACH)
|
if (m_action == PA_LOAD || m_action == PA_ATTACH)
|
||||||
return load(now);
|
return load(now, delayed);
|
||||||
if (m_action == PA_UNLOAD)
|
if (m_action == PA_UNLOAD)
|
||||||
return unload(now, reason);
|
return unload(now, reason, delayed);
|
||||||
if (m_action == PA_RELOAD)
|
if (m_action == PA_RELOAD)
|
||||||
return reload(now, reason);
|
return reload(now, reason, delayed);
|
||||||
|
|
||||||
META_ERROR("No pending action to retry for plugin '%s'; (status=%s, action=%s)", m_desc, str_status(), str_action());
|
META_ERROR("No pending action to retry for plugin '%s'; (status=%s, action=%s)", m_desc, str_status(), str_action());
|
||||||
return false;
|
return false;
|
||||||
@ -703,8 +709,9 @@ bool MPlugin::plugin_unload(plid_t plid, PLUG_LOADTIME now, PL_UNLOAD_REASON rea
|
|||||||
//try unload
|
//try unload
|
||||||
PLUG_ACTION old_action = m_action;
|
PLUG_ACTION old_action = m_action;
|
||||||
m_action = PA_UNLOAD;
|
m_action = PA_UNLOAD;
|
||||||
|
bool delayed;
|
||||||
|
|
||||||
if (unload(now, reason)) {
|
if (unload(now, reason, delayed)) {
|
||||||
META_DEBUG(1, "Unloaded plugin '%s'", m_desc);
|
META_DEBUG(1, "Unloaded plugin '%s'", m_desc);
|
||||||
pl_unloader->m_is_unloader = false;
|
pl_unloader->m_is_unloader = false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -89,9 +89,9 @@ public:
|
|||||||
|
|
||||||
bool platform_match(MPlugin* plugin) const; // check if a given plugin is the same but possibly for a different platform
|
bool platform_match(MPlugin* plugin) const; // check if a given plugin is the same but possibly for a different platform
|
||||||
|
|
||||||
bool load(PLUG_LOADTIME now); // load parsed plugin
|
bool load(PLUG_LOADTIME now, bool& delayed); // load parsed plugin
|
||||||
bool unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
|
bool unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason, bool& delayed);
|
||||||
bool reload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
|
bool reload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason, bool& delayed);
|
||||||
bool pause();
|
bool pause();
|
||||||
bool unpause();
|
bool unpause();
|
||||||
bool retry(PLUG_LOADTIME now, PL_UNLOAD_REASON reason); // if previously failed
|
bool retry(PLUG_LOADTIME now, PL_UNLOAD_REASON reason); // if previously failed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user