mirror of
https://github.com/matrix-construct/construct
synced 2024-09-26 18:38:52 +02:00
ircd:Ⓜ️:init::backfill: Improve info/errlog msg conditions.
This commit is contained in:
parent
a948b5f00f
commit
356e2301e9
1 changed files with 26 additions and 17 deletions
|
@ -14,6 +14,7 @@ namespace ircd::m::init::backfill
|
||||||
void handle_room(const room::id &);
|
void handle_room(const room::id &);
|
||||||
void worker();
|
void worker();
|
||||||
|
|
||||||
|
extern size_t count, complete;
|
||||||
extern ircd::run::changed handle_quit;
|
extern ircd::run::changed handle_quit;
|
||||||
extern std::unique_ptr<context> worker_context;
|
extern std::unique_ptr<context> worker_context;
|
||||||
extern ctx::pool *worker_pool;
|
extern ctx::pool *worker_pool;
|
||||||
|
@ -74,6 +75,12 @@ ircd::m::init::backfill::delay
|
||||||
{ "default", 15L },
|
{ "default", 15L },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
decltype(ircd::m::init::backfill::count)
|
||||||
|
ircd::m::init::backfill::count;
|
||||||
|
|
||||||
|
decltype(ircd::m::init::backfill::complete)
|
||||||
|
ircd::m::init::backfill::complete;
|
||||||
|
|
||||||
decltype(ircd::m::init::backfill::worker_pool)
|
decltype(ircd::m::init::backfill::worker_pool)
|
||||||
ircd::m::init::backfill::worker_pool;
|
ircd::m::init::backfill::worker_pool;
|
||||||
|
|
||||||
|
@ -210,9 +217,8 @@ try
|
||||||
// worker; the submission blocks when all pool workers are busy, as per
|
// worker; the submission blocks when all pool workers are busy, as per
|
||||||
// the pool::opts.
|
// the pool::opts.
|
||||||
ctx::dock dock;
|
ctx::dock dock;
|
||||||
size_t count(0), complete(0);
|
|
||||||
const ctx::uninterruptible ui;
|
const ctx::uninterruptible ui;
|
||||||
rooms::for_each(opts, [&pool, &count, &complete, &estimate, &dock]
|
rooms::for_each(opts, [&pool, &estimate, &dock]
|
||||||
(const room::id &room_id)
|
(const room::id &room_id)
|
||||||
{
|
{
|
||||||
if(unlikely(ctx::interruption_requested()))
|
if(unlikely(ctx::interruption_requested()))
|
||||||
|
@ -221,7 +227,7 @@ try
|
||||||
++count;
|
++count;
|
||||||
pool([&, room_id(std::string(room_id))] // asynchronous
|
pool([&, room_id(std::string(room_id))] // asynchronous
|
||||||
{
|
{
|
||||||
const unwind completed{[&complete, &dock]
|
const unwind completed{[&dock]
|
||||||
{
|
{
|
||||||
++complete;
|
++complete;
|
||||||
dock.notify_one();
|
dock.notify_one();
|
||||||
|
@ -253,32 +259,35 @@ try
|
||||||
// All rooms have been submitted to the pool but the pool workers might
|
// All rooms have been submitted to the pool but the pool workers might
|
||||||
// still be busy. If we unwind now the pool's dtor will kill the workers
|
// still be busy. If we unwind now the pool's dtor will kill the workers
|
||||||
// so we synchronize their completion here.
|
// so we synchronize their completion here.
|
||||||
dock.wait([&complete, &count]
|
dock.wait([]
|
||||||
{
|
{
|
||||||
return complete >= count;
|
return complete >= count;
|
||||||
});
|
});
|
||||||
|
|
||||||
log::notice
|
if(count)
|
||||||
{
|
log::notice
|
||||||
log, "Initial resynchronization of %zu rooms completed.",
|
{
|
||||||
count,
|
log, "Initial resynchronization of %zu rooms completed.",
|
||||||
};
|
count,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
catch(const ctx::interrupted &e)
|
catch(const ctx::interrupted &e)
|
||||||
{
|
{
|
||||||
log::derror
|
if(count)
|
||||||
{
|
log::derror
|
||||||
log, "Worker interrupted without completing resynchronization of all rooms."
|
{
|
||||||
};
|
log, "Worker interrupted without completing resynchronization of all rooms."
|
||||||
|
};
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch(const ctx::terminated &e)
|
catch(const ctx::terminated &e)
|
||||||
{
|
{
|
||||||
log::error
|
if(count)
|
||||||
{
|
log::error
|
||||||
log, "Worker terminated without completing resynchronization of all rooms."
|
{
|
||||||
};
|
log, "Worker terminated without completing resynchronization of all rooms."
|
||||||
|
};
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue