mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-30 19:00:29 +08:00
On win32, don't use SO_REUSEADDR for TCP sockets.
Per failure on buildfarm member baiji and subsequent discussion.
This commit is contained in:
parent
9539e64bc0
commit
0e92f9813e
@ -30,7 +30,7 @@
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.191 2007/03/03 19:32:54 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.192 2007/06/04 11:59:20 mha Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -337,6 +337,16 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
/*
|
||||
* Without the SO_REUSEADDR flag, a new postmaster can't be started right away after
|
||||
* a stop or crash, giving "address already in use" error on TCP ports.
|
||||
*
|
||||
* On win32, however, this behavior only happens if the SO_EXLUSIVEADDRUSE is set.
|
||||
* With SO_REUSEADDR, win32 allows multiple servers to listen on the same address,
|
||||
* resulting in unpredictable behavior. With no flags at all, win32 behaves as
|
||||
* Unix with SO_REUSEADDR.
|
||||
*/
|
||||
if (!IS_AF_UNIX(addr->ai_family))
|
||||
{
|
||||
if ((setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
|
||||
@ -349,6 +359,7 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef IPV6_V6ONLY
|
||||
if (addr->ai_family == AF_INET6)
|
||||
|
Loading…
Reference in New Issue
Block a user