mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Enable TCP_NODELAY.
PostgreSQL enables this option when available which seems like a good idea since we also buffer transmissions. Note that as in PostgreSQL there is no way to disable this option.
This commit is contained in:
parent
a1a0a23c6a
commit
967f2c0d7f
@ -63,6 +63,15 @@ sckOptionSet(int fd)
|
|||||||
|
|
||||||
ASSERT(socketLocal.init);
|
ASSERT(socketLocal.init);
|
||||||
|
|
||||||
|
// Disable the Nagle algorithm. This means that segments are always sent as soon as possible, even if there is only a small
|
||||||
|
// amount of data. Our internal buffering minimizes the benefit of this optimization so lower latency is preferred.
|
||||||
|
#ifdef TCP_NODELAY
|
||||||
|
int socketValue = 1;
|
||||||
|
|
||||||
|
THROW_ON_SYS_ERROR(
|
||||||
|
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &socketValue, sizeof(int)) == -1, ProtocolError, "unable set TCP_NODELAY");
|
||||||
|
#endif
|
||||||
|
|
||||||
// Enable TCP keepalives
|
// Enable TCP keepalives
|
||||||
if (socketLocal.keepAlive)
|
if (socketLocal.keepAlive)
|
||||||
{
|
{
|
||||||
|
@ -125,12 +125,20 @@ testRun(void)
|
|||||||
THROW_ON_SYS_ERROR(fd == -1, HostConnectError, "unable to create socket");
|
THROW_ON_SYS_ERROR(fd == -1, HostConnectError, "unable to create socket");
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("enable keep-alive and options");
|
TEST_TITLE("enable options");
|
||||||
|
|
||||||
sckInit(true, 32, 3113, 818);
|
sckInit(true, 32, 3113, 818);
|
||||||
sckOptionSet(fd);
|
sckOptionSet(fd);
|
||||||
|
|
||||||
socklen_t socketValueSize = sizeof(int);
|
socklen_t socketValueSize = sizeof(int);
|
||||||
|
int noDelayValue = 0;
|
||||||
|
|
||||||
|
THROW_ON_SYS_ERROR(
|
||||||
|
getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &noDelayValue, &socketValueSize) == -1, ProtocolError,
|
||||||
|
"unable get TCP_NO_DELAY");
|
||||||
|
|
||||||
|
TEST_RESULT_INT(noDelayValue, 1, "check TCP_NODELAY");
|
||||||
|
|
||||||
int keepAliveValue = 0;
|
int keepAliveValue = 0;
|
||||||
|
|
||||||
THROW_ON_SYS_ERROR(
|
THROW_ON_SYS_ERROR(
|
||||||
|
Loading…
Reference in New Issue
Block a user