mirror of
https://github.com/matrix-construct/construct
synced 2025-03-13 21:10:32 +01:00
ircd:Ⓜ️:v1: Add convenience option for dynamic memory to all requests.
This commit is contained in:
parent
d3e6b20f14
commit
13c4a5b79b
12 changed files with 44 additions and 11 deletions
|
@ -40,4 +40,5 @@ struct ircd::m::v1::backfill::opts
|
|||
server::out out;
|
||||
server::in in;
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {true};
|
||||
};
|
||||
|
|
|
@ -45,4 +45,5 @@ struct ircd::m::v1::event::opts
|
|||
server::out out;
|
||||
server::in in;
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {false};
|
||||
};
|
||||
|
|
|
@ -37,4 +37,5 @@ struct ircd::m::v1::groups::publicised::opts
|
|||
server::out out;
|
||||
server::in in;
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {false};
|
||||
};
|
||||
|
|
|
@ -37,4 +37,5 @@ struct ircd::m::v1::invite::opts
|
|||
server::out out;
|
||||
server::in in;
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {false};
|
||||
};
|
||||
|
|
|
@ -38,4 +38,5 @@ struct ircd::m::v1::make_join::opts
|
|||
server::out out;
|
||||
server::in in;
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {false};
|
||||
};
|
||||
|
|
|
@ -42,6 +42,7 @@ struct ircd::m::v1::query::opts
|
|||
server::out out;
|
||||
server::in in;
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {false};
|
||||
|
||||
opts(const net::hostport &remote)
|
||||
:remote{remote}
|
||||
|
|
|
@ -64,6 +64,7 @@ struct ircd::m::v1::send::opts
|
|||
/// The lower-level server::request::opts configuration to attach to
|
||||
/// this request.
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {false};
|
||||
};
|
||||
|
||||
/// Helper for dealing with response content from a /send/.
|
||||
|
|
|
@ -37,4 +37,5 @@ struct ircd::m::v1::send_join::opts
|
|||
server::out out;
|
||||
server::in in;
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {true};
|
||||
};
|
||||
|
|
|
@ -40,4 +40,5 @@ struct ircd::m::v1::state::opts
|
|||
server::out out;
|
||||
server::in in;
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {true};
|
||||
};
|
||||
|
|
|
@ -39,6 +39,7 @@ struct ircd::m::v1::user::opts
|
|||
server::out out;
|
||||
server::in in;
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {false};
|
||||
|
||||
opts(const net::hostport &remote)
|
||||
:remote{remote}
|
||||
|
|
|
@ -37,4 +37,5 @@ struct ircd::m::v1::version::opts
|
|||
server::out out;
|
||||
server::in in;
|
||||
const struct server::request::opts *sopts {nullptr};
|
||||
bool dynamic {false};
|
||||
};
|
||||
|
|
44
ircd/m/v1.cc
44
ircd/m/v1.cc
|
@ -55,7 +55,9 @@ ircd::m::v1::groups::publicised::publicised(const id::node &node,
|
|||
{
|
||||
consume(buf, size(opts.out.head));
|
||||
opts.in.head = buf;
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
@ -124,7 +126,9 @@ ircd::m::v1::send::send(const string_view &txnid,
|
|||
if(!size(opts.in))
|
||||
{
|
||||
opts.in.head = buf + size(opts.out.head);
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
@ -197,7 +201,9 @@ ircd::m::v1::backfill::backfill(const room::id &room_id,
|
|||
if(!size(opts.in))
|
||||
{
|
||||
opts.in.head = buf + size(opts.out.head);
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
@ -270,7 +276,9 @@ ircd::m::v1::state::state(const room::id &room_id,
|
|||
if(!size(opts.in))
|
||||
{
|
||||
opts.in.head = buf + size(opts.out.head);
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
@ -331,7 +339,9 @@ ircd::m::v1::event::event(const m::event::id &event_id,
|
|||
if(!size(opts.in))
|
||||
{
|
||||
opts.in.head = buf + size(opts.out.head);
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
@ -385,7 +395,9 @@ ircd::m::v1::invite::invite(const room::id &room_id,
|
|||
if(!size(opts.in))
|
||||
{
|
||||
opts.in.head = buf + size(opts.out.head);
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
@ -439,7 +451,9 @@ ircd::m::v1::send_join::send_join(const room::id &room_id,
|
|||
if(!size(opts.in))
|
||||
{
|
||||
opts.in.head = buf + size(opts.out.head);
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
@ -503,7 +517,9 @@ ircd::m::v1::make_join::make_join(const room::id &room_id,
|
|||
if(!size(opts.in))
|
||||
{
|
||||
opts.in.head = buf + size(opts.out.head);
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
@ -554,7 +570,9 @@ ircd::m::v1::user::devices::devices(const id::user &user_id,
|
|||
if(!size(opts.in))
|
||||
{
|
||||
opts.in.head = buf + size(opts.out.head);
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
@ -762,7 +780,9 @@ ircd::m::v1::query::query(const string_view &type,
|
|||
if(!size(opts.in))
|
||||
{
|
||||
opts.in.head = buf + size(opts.out.head);
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
@ -799,7 +819,9 @@ ircd::m::v1::version::version(const mutable_buffer &buf,
|
|||
if(!size(opts.in))
|
||||
{
|
||||
opts.in.head = buf + size(opts.out.head);
|
||||
opts.in.content = opts.in.head; // server::request will auto partition
|
||||
opts.in.content = opts.dynamic?
|
||||
mutable_buffer{}: // server::request will allocate new mem
|
||||
opts.in.head; // server::request will auto partition
|
||||
}
|
||||
|
||||
return server::request
|
||||
|
|
Loading…
Add table
Reference in a new issue