Skip to content

Commit a64bf0a

Browse files
committed
Make the Windows tcp keepalive support depend on the existance of the
SIO_KEEPALIVE_VALS define instead of just WIN32, since MingW doesn't support this API (yet?).
1 parent 672efc0 commit a64bf0a

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/backend/libpq/pqcomm.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
3131
* Portions Copyright (c) 1994, Regents of the University of California
3232
*
33-
* $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.211 2010/07/08 10:20:12 mha Exp $
33+
* $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.212 2010/07/08 16:19:50 mha Exp $
3434
*
3535
*-------------------------------------------------------------------------
3636
*/
@@ -83,7 +83,7 @@
8383
#ifdef HAVE_UTIME_H
8484
#include <utime.h>
8585
#endif
86-
#ifdef WIN32
86+
#ifdef WIN32_ONLY_COMPILER /* mstcpip.h is missing on mingw */
8787
#include <mstcpip.h>
8888
#endif
8989

@@ -1323,7 +1323,7 @@ pq_endcopyout(bool errorAbort)
13231323
* actually set them to zero, not default), therefor we fallback to
13241324
* the out-of-the-box default instead.
13251325
*/
1326-
#ifdef WIN32
1326+
#if defined(WIN32) && defined(SIO_KEEPALIVE_VALS)
13271327
static int
13281328
pq_setkeepaliveswin32(Port *port, int idle, int interval)
13291329
{
@@ -1412,7 +1412,7 @@ pq_setkeepalivesidle(int idle, Port *port)
14121412
if (port == NULL || IS_AF_UNIX(port->laddr.addr.ss_family))
14131413
return STATUS_OK;
14141414

1415-
#if defined(TCP_KEEPIDLE) || defined(TCP_KEEPALIVE) || defined(WIN32)
1415+
#if defined(TCP_KEEPIDLE) || defined(TCP_KEEPALIVE) || defined(SIO_KEEPALIVE_VALS)
14161416
if (idle == port->keepalives_idle)
14171417
return STATUS_OK;
14181418

@@ -1451,7 +1451,7 @@ pq_setkeepalivesidle(int idle, Port *port)
14511451
#else /* WIN32 */
14521452
return pq_setkeepaliveswin32(port, idle, port->keepalives_interval);
14531453
#endif
1454-
#else /* TCP_KEEPIDLE || WIN32 */
1454+
#else /* TCP_KEEPIDLE || SIO_KEEPALIVE_VALS */
14551455
if (idle != 0)
14561456
{
14571457
elog(LOG, "setting the keepalive idle time is not supported");
@@ -1464,7 +1464,7 @@ pq_setkeepalivesidle(int idle, Port *port)
14641464
int
14651465
pq_getkeepalivesinterval(Port *port)
14661466
{
1467-
#if defined(TCP_KEEPINTVL) || defined(WIN32)
1467+
#if defined(TCP_KEEPINTVL) || defined(SIO_KEEPALIVE_VALS)
14681468
if (port == NULL || IS_AF_UNIX(port->laddr.addr.ss_family))
14691469
return 0;
14701470

@@ -1501,7 +1501,7 @@ pq_setkeepalivesinterval(int interval, Port *port)
15011501
if (port == NULL || IS_AF_UNIX(port->laddr.addr.ss_family))
15021502
return STATUS_OK;
15031503

1504-
#if defined(TCP_KEEPINTVL) || defined (WIN32)
1504+
#if defined(TCP_KEEPINTVL) || defined (SIO_KEEPALIVE_VALS)
15051505
if (interval == port->keepalives_interval)
15061506
return STATUS_OK;
15071507

src/interfaces/libpq/fe-connect.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.397 2010/07/08 10:20:12 mha Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.398 2010/07/08 16:19:50 mha Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -38,7 +38,9 @@
3838
#endif
3939
#define near
4040
#include <shlobj.h>
41+
#ifdef WIN32_ONLY_COMPILER /* mstcpip.h is missing on mingw */
4142
#include <mstcpip.h>
43+
#endif
4244
#else
4345
#include <sys/socket.h>
4446
#include <netdb.h>
@@ -1093,6 +1095,7 @@ setKeepalivesCount(PGconn *conn)
10931095
}
10941096

10951097
#else /* Win32 */
1098+
#ifdef SIO_KEEPALIVE_VALS
10961099
/*
10971100
* Enable keepalives and set the keepalive values on Win32,
10981101
* where they are always set in one batch.
@@ -1137,6 +1140,7 @@ setKeepalivesWin32(PGconn *conn)
11371140
}
11381141
return 1;
11391142
}
1143+
#endif /* SIO_KEEPALIVE_VALS */
11401144
#endif /* WIN32 */
11411145

11421146
/* ----------
@@ -1555,8 +1559,10 @@ PQconnectPoll(PGconn *conn)
15551559
|| !setKeepalivesCount(conn))
15561560
err = 1;
15571561
#else /* WIN32 */
1562+
#ifdef SIO_KEEPALIVE_VALS
15581563
else if (!setKeepalivesWin32(conn))
15591564
err = 1;
1565+
#endif /* SIO_KEEPALIVE_VALS */
15601566
#endif /* WIN32 */
15611567

15621568
if (err)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy