mirror of
https://github.com/matrix-construct/construct
synced 2025-01-20 19:41:55 +01:00
construct: Fix the conf rehash interface for SIGUSR1.
This commit is contained in:
parent
63c70ecdfc
commit
1973e2c086
5 changed files with 35 additions and 5 deletions
|
@ -15,6 +15,9 @@
|
|||
namespace fs = ircd::fs;
|
||||
using ircd::string_view;
|
||||
|
||||
decltype(construct::homeserver::primary)
|
||||
construct::homeserver::primary;
|
||||
|
||||
construct::homeserver::homeserver(struct ircd::m::homeserver::opts opts)
|
||||
try
|
||||
:opts
|
||||
|
@ -45,6 +48,8 @@ try
|
|||
}
|
||||
}
|
||||
{
|
||||
assert(!primary);
|
||||
primary = this;
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
|
@ -59,4 +64,6 @@ catch(const std::exception &e)
|
|||
construct::homeserver::~homeserver()
|
||||
noexcept
|
||||
{
|
||||
assert(primary);
|
||||
primary = nullptr;
|
||||
}
|
||||
|
|
|
@ -23,4 +23,6 @@ struct construct::homeserver
|
|||
public:
|
||||
homeserver(struct ircd::m::homeserver::opts);
|
||||
~homeserver() noexcept;
|
||||
|
||||
static homeserver *primary;
|
||||
};
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#include <ircd/ircd.h> // must include because asio.h.gch is fPIC
|
||||
#include <ircd/matrix.h>
|
||||
#include <ircd/asio.h>
|
||||
#include "construct.h"
|
||||
#include "homeserver.h"
|
||||
#include "signals.h"
|
||||
#include "console.h"
|
||||
|
||||
|
@ -225,24 +226,29 @@ try
|
|||
return;
|
||||
}
|
||||
|
||||
if(!homeserver::primary || !homeserver::primary->module[0])
|
||||
return;
|
||||
|
||||
// This signal handler (though not a *real* signal handler) is still
|
||||
// running on the main async stack and not an ircd::ctx. The reload
|
||||
// function does a lot of IO so it requires an ircd::ctx.
|
||||
ircd::context{[]
|
||||
{
|
||||
ircd::mods::import<void ()> reload_conf
|
||||
static ircd::mods::import<void (ircd::m::homeserver *)> rehash
|
||||
{
|
||||
"s_conf", "reload_conf"
|
||||
homeserver::primary->module[0], "ircd::m::homeserver::rehash"
|
||||
};
|
||||
|
||||
reload_conf();
|
||||
assert(homeserver::primary->hs);
|
||||
rehash(homeserver::primary->hs.get());
|
||||
}};
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
ircd::log::error
|
||||
{
|
||||
"SIGUSR1 handler: %s", e.what()
|
||||
"SIGUSR1 handler :%s",
|
||||
e.what()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ struct ircd::m::homeserver
|
|||
/// Factory to create homeserver with single procedure for shlib purposes.
|
||||
static homeserver *init(const struct opts *);
|
||||
static void fini(homeserver *) noexcept;
|
||||
static bool rehash(homeserver *);
|
||||
};
|
||||
|
||||
struct ircd::m::homeserver::key
|
||||
|
|
|
@ -213,6 +213,20 @@ noexcept
|
|||
delete homeserver;
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::homeserver::rehash(homeserver *const homeserver)
|
||||
{
|
||||
if(!homeserver)
|
||||
return false;
|
||||
|
||||
if(!homeserver->conf)
|
||||
return false;
|
||||
|
||||
homeserver->conf->load();
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// homeserver::homeserver::homeserver
|
||||
//
|
||||
|
|
Loading…
Add table
Reference in a new issue