ircd::net: Add state for nodelay in socket w/ condition to elide; interface overloads.

This commit is contained in:
Jason Volk 2023-03-19 19:48:06 -07:00
parent b07fa8c110
commit 13f3d1ebc6
3 changed files with 25 additions and 2 deletions

View File

@ -20,6 +20,7 @@ namespace ircd::net
bool blocking(const socket &, system_t);
bool blocking(const socket &);
bool nopush(const socket &);
bool nodelay(const socket &, system_t);
bool nodelay(const socket &);
bool quickack(const socket &);
bool keepalive(const socket &);
@ -35,6 +36,7 @@ namespace ircd::net
bool blocking(socket &, const bool, system_t);
bool blocking(socket &, const bool);
bool nopush(socket &, const bool);
bool nodelay(socket &, const bool, system_t);
bool nodelay(socket &, const bool);
bool quickack(socket &, const bool);
bool keepalive(socket &, const bool);

View File

@ -74,6 +74,7 @@ ircd::net::socket
bool timer_set {false}; // boolean lockout
bool timedout {false};
bool fini {false};
mutable bool _nodelay {false}; // userspace tracking only
void call_user(const eptr_handler &, const error_code &) noexcept;
void call_user(const ec_handler &, const error_code &) noexcept;

View File

@ -1081,10 +1081,22 @@ ircd::net::quickack(socket &socket,
bool
ircd::net::nodelay(socket &socket,
const bool b)
{
if(likely(nodelay(socket) != b))
nodelay(socket, b, system);
return true;
}
bool
ircd::net::nodelay(socket &socket,
const bool b,
system_t)
{
const ip::tcp::no_delay option{b};
ip::tcp::socket &sd(socket);
sd.set_option(option);
socket._nodelay = b;
return true;
}
@ -1279,12 +1291,20 @@ ircd::net::quickack(const socket &socket)
#endif
bool
ircd::net::nodelay(const socket &socket)
ircd::net::nodelay(const socket &socket,
system_t)
{
const ip::tcp::socket &sd(socket);
ip::tcp::no_delay option;
sd.get_option(option);
return option.value();
mutable_cast(socket)._nodelay = option.value();
return socket._nodelay;
}
bool
ircd::net::nodelay(const socket &socket)
{
return socket._nodelay;
}
bool