construct: Fix the conf rehash interface for SIGUSR1.
This commit is contained in:
parent
63c70ecdfc
commit
1973e2c086
|
@ -15,6 +15,9 @@
|
||||||
namespace fs = ircd::fs;
|
namespace fs = ircd::fs;
|
||||||
using ircd::string_view;
|
using ircd::string_view;
|
||||||
|
|
||||||
|
decltype(construct::homeserver::primary)
|
||||||
|
construct::homeserver::primary;
|
||||||
|
|
||||||
construct::homeserver::homeserver(struct ircd::m::homeserver::opts opts)
|
construct::homeserver::homeserver(struct ircd::m::homeserver::opts opts)
|
||||||
try
|
try
|
||||||
:opts
|
:opts
|
||||||
|
@ -45,6 +48,8 @@ try
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
assert(!primary);
|
||||||
|
primary = this;
|
||||||
}
|
}
|
||||||
catch(const std::exception &e)
|
catch(const std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -59,4 +64,6 @@ catch(const std::exception &e)
|
||||||
construct::homeserver::~homeserver()
|
construct::homeserver::~homeserver()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
assert(primary);
|
||||||
|
primary = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,4 +23,6 @@ struct construct::homeserver
|
||||||
public:
|
public:
|
||||||
homeserver(struct ircd::m::homeserver::opts);
|
homeserver(struct ircd::m::homeserver::opts);
|
||||||
~homeserver() noexcept;
|
~homeserver() noexcept;
|
||||||
|
|
||||||
|
static homeserver *primary;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,9 +8,10 @@
|
||||||
// copyright notice and this permission notice is present in all copies. The
|
// copyright notice and this permission notice is present in all copies. The
|
||||||
// full license for this software is available in the LICENSE file.
|
// 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 <ircd/asio.h>
|
||||||
#include "construct.h"
|
#include "construct.h"
|
||||||
|
#include "homeserver.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
|
||||||
|
@ -225,24 +226,29 @@ try
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!homeserver::primary || !homeserver::primary->module[0])
|
||||||
|
return;
|
||||||
|
|
||||||
// This signal handler (though not a *real* signal handler) is still
|
// This signal handler (though not a *real* signal handler) is still
|
||||||
// running on the main async stack and not an ircd::ctx. The reload
|
// 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.
|
// function does a lot of IO so it requires an ircd::ctx.
|
||||||
ircd::context{[]
|
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)
|
catch(const std::exception &e)
|
||||||
{
|
{
|
||||||
ircd::log::error
|
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.
|
/// Factory to create homeserver with single procedure for shlib purposes.
|
||||||
static homeserver *init(const struct opts *);
|
static homeserver *init(const struct opts *);
|
||||||
static void fini(homeserver *) noexcept;
|
static void fini(homeserver *) noexcept;
|
||||||
|
static bool rehash(homeserver *);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ircd::m::homeserver::key
|
struct ircd::m::homeserver::key
|
||||||
|
|
|
@ -213,6 +213,20 @@ noexcept
|
||||||
delete homeserver;
|
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
|
// homeserver::homeserver::homeserver
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue