mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-12 10:04:14 +02:00
Fix detection of keepalive options on Linux.
This code stanza was not being included on Linux platforms because of a missing header file. Also update the order of operations and make the timeout calculations more sensible.
This commit is contained in:
parent
e9c1569d8e
commit
4b24a74afb
@ -27,6 +27,15 @@
|
||||
</release-feature-list>
|
||||
|
||||
<release-improvement-list>
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-contributor id="marc.cousin"/>
|
||||
<release-item-reviewer id="david.steele"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Fix detection of keepalive options on <proper>Linux</proper>.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-contributor id="marc.cousin"/>
|
||||
|
@ -16,6 +16,11 @@ TLS Client
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/x509v3.h>
|
||||
@ -617,7 +622,7 @@ tlsClientOpen(TlsClient *this)
|
||||
int socketValue = 1;
|
||||
|
||||
THROW_ON_SYS_ERROR(
|
||||
setsockopt(this->socket, SOL_SOCKET, SO_KEEPALIVE, &socketValue, sizeof(int)) == -1, ProtocolError,
|
||||
setsockopt(this->socket, IPPROTO_TCP, SO_KEEPALIVE, &socketValue, sizeof(int)) == -1, ProtocolError,
|
||||
"unable set SO_KEEPALIVE");
|
||||
|
||||
// Set per-connection keepalive options if they are available
|
||||
@ -625,18 +630,19 @@ tlsClientOpen(TlsClient *this)
|
||||
socketValue = 3;
|
||||
|
||||
THROW_ON_SYS_ERROR(
|
||||
setsockopt(this->socket, SOL_SOCKET, TCP_KEEPIDLE, &socketValue, sizeof(int)) == -1, ProtocolError,
|
||||
setsockopt(this->socket, IPPROTO_TCP, TCP_KEEPCNT, &socketValue, sizeof(int)) == -1, ProtocolError,
|
||||
"unable set SO_KEEPCNT");
|
||||
|
||||
// First try + n failures to get to the timeout
|
||||
socketValue = (int)this->timeout / (socketValue + 1);
|
||||
|
||||
THROW_ON_SYS_ERROR(
|
||||
setsockopt(this->socket, IPPROTO_TCP, TCP_KEEPIDLE, &socketValue, sizeof(int)) == -1, ProtocolError,
|
||||
"unable set SO_KEEPIDLE");
|
||||
|
||||
THROW_ON_SYS_ERROR(
|
||||
setsockopt(this->socket, SOL_SOCKET, TCP_KEEPINTVL, &socketValue, sizeof(int)) == -1, ProtocolError,
|
||||
setsockopt(this->socket, IPPROTO_TCP, TCP_KEEPINTVL, &socketValue, sizeof(int)) == -1, ProtocolError,
|
||||
"unable set SO_KEEPINTVL");
|
||||
|
||||
socketValue = (int)this->timeout / socketValue;
|
||||
|
||||
THROW_ON_SYS_ERROR(
|
||||
setsockopt(this->socket, SOL_SOCKET, TCP_KEEPCNT, &socketValue, sizeof(int)) == -1, ProtocolError,
|
||||
"unable set SO_KEEPCNT");
|
||||
#endif
|
||||
|
||||
// Negotiate TLS
|
||||
|
Loading…
Reference in New Issue
Block a user