mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
modules/s_fetch: Add a request map cleanup pass.
This commit is contained in:
parent
de710494d7
commit
66c73e2a65
2 changed files with 34 additions and 6 deletions
|
@ -327,6 +327,7 @@ try
|
|||
});
|
||||
});
|
||||
|
||||
request_cleanup();
|
||||
request_handle();
|
||||
}
|
||||
}
|
||||
|
@ -341,6 +342,19 @@ catch(const std::exception &e)
|
|||
throw;
|
||||
}
|
||||
|
||||
void
|
||||
ircd::m::fetch::request_cleanup()
|
||||
{
|
||||
auto it(begin(requests));
|
||||
while(it != end(requests))
|
||||
{
|
||||
if(it->finished && empty(it->buf))
|
||||
it = requests.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ircd::m::fetch::request_handle()
|
||||
{
|
||||
|
@ -433,21 +447,18 @@ catch(const std::exception &e)
|
|||
void
|
||||
ircd::m::fetch::eval_handle()
|
||||
{
|
||||
assert(!complete.empty());
|
||||
const unwind pop{[]
|
||||
{
|
||||
assert(!complete.empty());
|
||||
complete.pop_front();
|
||||
}};
|
||||
|
||||
const auto &it
|
||||
const auto it
|
||||
{
|
||||
complete.front()
|
||||
};
|
||||
|
||||
const unwind erase{[&it]
|
||||
{
|
||||
requests.erase(it);
|
||||
}};
|
||||
|
||||
eval_handle(it);
|
||||
}
|
||||
|
||||
|
@ -460,9 +471,24 @@ try
|
|||
const_cast<fetch::request &>(*it)
|
||||
};
|
||||
|
||||
const unwind free{[&request]
|
||||
{
|
||||
request._buf = {};
|
||||
request.buf = request._buf;
|
||||
}};
|
||||
|
||||
if(request.eptr)
|
||||
std::rethrow_exception(request.eptr);
|
||||
|
||||
log::debug
|
||||
{
|
||||
log, "eval handling %s in %s (r:%zu c:%zu)",
|
||||
string_view{request.event_id},
|
||||
string_view{request.room_id},
|
||||
requests.size(),
|
||||
complete.size(),
|
||||
};
|
||||
|
||||
const json::object &event
|
||||
{
|
||||
request
|
||||
|
@ -551,6 +577,7 @@ ircd::m::fetch::request::start()
|
|||
void
|
||||
ircd::m::fetch::request::start(m::v1::event::opts &opts)
|
||||
{
|
||||
assert(finished == 0);
|
||||
if(!started)
|
||||
started = ircd::time();
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace ircd::m::fetch
|
|||
static void eval_worker();
|
||||
static void request_handle(const decltype(requests)::iterator &);
|
||||
static void request_handle();
|
||||
static void request_cleanup();
|
||||
static void request_worker();
|
||||
static void hook_handler(const event &, vm::eval &);
|
||||
static void init();
|
||||
|
|
Loading…
Reference in a new issue