mirror of
https://github.com/matrix-construct/construct
synced 2024-12-28 00:14:07 +01:00
modules/m_fetch: Use cancel interface; minor cleanup.
This commit is contained in:
parent
3958757dbb
commit
130a86e27c
2 changed files with 18 additions and 6 deletions
|
@ -604,7 +604,18 @@ bool
|
|||
IRCD_MODULE_EXPORT
|
||||
ircd::m::fetch::cancel(request &request)
|
||||
{
|
||||
return false;
|
||||
bool ret{false};
|
||||
if(request.finished == -1)
|
||||
return ret;
|
||||
|
||||
if(request.finished == 0)
|
||||
{
|
||||
assert(request.started);
|
||||
ret |= server::cancel(request);
|
||||
}
|
||||
|
||||
request.finished = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t
|
||||
|
@ -661,6 +672,7 @@ try
|
|||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
fetch::cancel(request);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -694,7 +706,7 @@ try
|
|||
return std::any_of(begin(requests), end(requests), []
|
||||
(const request &r)
|
||||
{
|
||||
return r.finished <= 0;
|
||||
return r.finished == -1 || r.finished == 0;
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -14,10 +14,6 @@ namespace ircd::m::fetch
|
|||
struct request; // m/fetch.h
|
||||
struct evaltab;
|
||||
|
||||
static bool operator<(const request &a, const request &b) noexcept;
|
||||
static bool operator<(const request &a, const string_view &b) noexcept;
|
||||
static bool operator<(const string_view &a, const request &b) noexcept;
|
||||
|
||||
extern ctx::dock dock;
|
||||
extern std::set<request, std::less<>> requests;
|
||||
extern std::multimap<room::id, request *> rooms;
|
||||
|
@ -30,6 +26,10 @@ namespace ircd::m::fetch
|
|||
extern conf::item<seconds> timeout;
|
||||
extern conf::item<bool> enable;
|
||||
|
||||
static bool operator<(const request &a, const request &b) noexcept;
|
||||
static bool operator<(const request &a, const string_view &b) noexcept;
|
||||
static bool operator<(const string_view &a, const request &b) noexcept;
|
||||
|
||||
static bool timedout(const request &, const time_t &now);
|
||||
static string_view select_origin(request &, const string_view &);
|
||||
static string_view select_random_origin(request &);
|
||||
|
|
Loading…
Reference in a new issue