mirror of
https://github.com/matrix-construct/construct
synced 2024-06-08 04:58:58 +02:00
ircd::net: Allow designated and implicit constructions for close_opts.
This commit is contained in:
parent
14f55f6110
commit
b3832541ff
|
@ -56,7 +56,9 @@ struct ircd::client
|
||||||
size_t write_all(const net::const_buffers &);
|
size_t write_all(const net::const_buffers &);
|
||||||
size_t write_all(const const_buffer &);
|
size_t write_all(const const_buffer &);
|
||||||
void close(const net::close_opts &, net::close_callback);
|
void close(const net::close_opts &, net::close_callback);
|
||||||
ctx::future<void> close(const net::close_opts & = {});
|
void close(const net::dc, net::close_callback);
|
||||||
|
ctx::future<void> close(const net::close_opts &);
|
||||||
|
ctx::future<void> close(const net::dc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void discard_unconsumed(const http::request::head &);
|
void discard_unconsumed(const http::request::head &);
|
||||||
|
|
|
@ -19,9 +19,11 @@ namespace ircd::net
|
||||||
|
|
||||||
// Callback-based closer.
|
// Callback-based closer.
|
||||||
void close(socket &, const close_opts &, close_callback);
|
void close(socket &, const close_opts &, close_callback);
|
||||||
|
void close(socket &, const dc &, close_callback);
|
||||||
|
|
||||||
// Future-based closer.
|
// Future-based closer.
|
||||||
ctx::future<void> close(socket &, const close_opts & = close_opts_default);
|
ctx::future<void> close(socket &, const close_opts & = close_opts_default);
|
||||||
|
ctx::future<void> close(socket &, const dc &);
|
||||||
|
|
||||||
// Fire-and-forget helper callback for close().
|
// Fire-and-forget helper callback for close().
|
||||||
extern const close_callback close_ignore;
|
extern const close_callback close_ignore;
|
||||||
|
@ -44,9 +46,6 @@ struct ircd::net::close_opts
|
||||||
{
|
{
|
||||||
static conf::item<milliseconds> default_timeout;
|
static conf::item<milliseconds> default_timeout;
|
||||||
|
|
||||||
close_opts() = default;
|
|
||||||
close_opts(const net::dc &);
|
|
||||||
|
|
||||||
/// The type of close() to be conducted is specified here.
|
/// The type of close() to be conducted is specified here.
|
||||||
net::dc type { dc::SSL_NOTIFY };
|
net::dc type { dc::SSL_NOTIFY };
|
||||||
|
|
||||||
|
@ -57,10 +56,3 @@ struct ircd::net::close_opts
|
||||||
/// the disconnect (useful for adding an SO_LINGER time etc).
|
/// the disconnect (useful for adding an SO_LINGER time etc).
|
||||||
const sock_opts *sopts { nullptr };
|
const sock_opts *sopts { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Allows for implicit construction of close_opts in arguments to close()
|
|
||||||
/// without requiring brackets for the close_opts& argument.
|
|
||||||
inline
|
|
||||||
ircd::net::close_opts::close_opts(const net::dc &type)
|
|
||||||
:type{type}
|
|
||||||
{}
|
|
||||||
|
|
|
@ -93,7 +93,8 @@ struct ircd::server::link
|
||||||
void submit(request &);
|
void submit(request &);
|
||||||
|
|
||||||
// control panel
|
// control panel
|
||||||
bool close(const net::close_opts & = net::close_opts_default);
|
bool close(const net::close_opts &);
|
||||||
|
bool close(const net::dc = net::dc::SSL_NOTIFY);
|
||||||
bool open(const net::open_opts &);
|
bool open(const net::open_opts &);
|
||||||
|
|
||||||
link(server::peer &);
|
link(server::peer &);
|
||||||
|
|
|
@ -1048,6 +1048,15 @@ ircd::client::discard_unconsumed(const http::request::head &head)
|
||||||
assert(content_consumed == head.content_length);
|
assert(content_consumed == head.content_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ircd::ctx::future<void>
|
||||||
|
ircd::client::close(const net::dc type)
|
||||||
|
{
|
||||||
|
return close(net::close_opts
|
||||||
|
{
|
||||||
|
.type = type,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ircd::ctx::future<void>
|
ircd::ctx::future<void>
|
||||||
ircd::client::close(const net::close_opts &opts)
|
ircd::client::close(const net::close_opts &opts)
|
||||||
{
|
{
|
||||||
|
@ -1056,6 +1065,18 @@ ircd::client::close(const net::close_opts &opts)
|
||||||
ctx::already;
|
ctx::already;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ircd::client::close(const net::dc type,
|
||||||
|
net::close_callback callback)
|
||||||
|
{
|
||||||
|
const net::close_opts opts
|
||||||
|
{
|
||||||
|
.type = type,
|
||||||
|
};
|
||||||
|
|
||||||
|
close(opts, std::move(callback));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::client::close(const net::close_opts &opts,
|
ircd::client::close(const net::close_opts &opts,
|
||||||
net::close_callback callback)
|
net::close_callback callback)
|
||||||
|
|
29
ircd/net.cc
29
ircd/net.cc
|
@ -680,10 +680,8 @@ ircd::net::close_opts::default_timeout
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Static instance of default close options.
|
/// Static instance of default close options.
|
||||||
ircd::net::close_opts
|
decltype(ircd::net::close_opts_default)
|
||||||
const ircd::net::close_opts_default
|
ircd::net::close_opts_default;
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Static helper callback which may be passed to the callback-based overload
|
/// Static helper callback which may be passed to the callback-based overload
|
||||||
/// of close(). This callback does nothing.
|
/// of close(). This callback does nothing.
|
||||||
|
@ -694,6 +692,16 @@ const ircd::net::close_ignore{[]
|
||||||
return;
|
return;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
ircd::ctx::future<void>
|
||||||
|
ircd::net::close(socket &s,
|
||||||
|
const dc &type)
|
||||||
|
{
|
||||||
|
return close(s, close_opts
|
||||||
|
{
|
||||||
|
.type = type,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ircd::ctx::future<void>
|
ircd::ctx::future<void>
|
||||||
ircd::net::close(socket &socket,
|
ircd::net::close(socket &socket,
|
||||||
const close_opts &opts)
|
const close_opts &opts)
|
||||||
|
@ -713,6 +721,19 @@ ircd::net::close(socket &socket,
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ircd::net::close(socket &s,
|
||||||
|
const dc &type,
|
||||||
|
close_callback cb)
|
||||||
|
{
|
||||||
|
const close_opts opts
|
||||||
|
{
|
||||||
|
.type = type,
|
||||||
|
};
|
||||||
|
|
||||||
|
return close(s, opts, std::move(cb));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::net::close(socket &socket,
|
ircd::net::close(socket &socket,
|
||||||
const close_opts &opts,
|
const close_opts &opts,
|
||||||
|
|
|
@ -2424,6 +2424,15 @@ ircd::server::link::handle_open(std::exception_ptr eptr)
|
||||||
peer->handle_open(*this, std::move(eptr));
|
peer->handle_open(*this, std::move(eptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::server::link::close(const net::dc type)
|
||||||
|
{
|
||||||
|
return close(net::close_opts
|
||||||
|
{
|
||||||
|
.type = type,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::server::link::close(const net::close_opts &close_opts)
|
ircd::server::link::close(const net::close_opts &close_opts)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue