Skip to content

Commit 5c9e9c0

Browse files
committed
Set Win32 server-size socket buffer to 32k, for performance reasons.
Yoshiyuki Asaba
1 parent 99c2b8b commit 5c9e9c0

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/backend/libpq/pqcomm.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Portions Copyright (c) 1996-2006, 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.186 2006/07/14 05:28:27 tgl Exp $
33+
* $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.187 2006/08/11 20:44:20 momjian Exp $
3434
*
3535
*-------------------------------------------------------------------------
3636
*/
@@ -593,6 +593,20 @@ StreamConnection(int server_fd, Port *port)
593593
return STATUS_ERROR;
594594
}
595595

596+
#ifdef WIN32
597+
/*
598+
* This is a Win32 socket optimization. The ideal size is 32k.
599+
* http://support.microsoft.com/kb/823764/EN-US/
600+
*/
601+
on = PQ_BUFFER_SIZE * 4;
602+
if (setsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &on,
603+
sizeof(on)) < 0)
604+
{
605+
elog(LOG, "setsockopt(SO_SNDBUF) failed: %m");
606+
return STATUS_ERROR;
607+
}
608+
#endif
609+
596610
/*
597611
* Also apply the current keepalive parameters. If we fail to set a
598612
* parameter, don't error out, because these aren't universally

0 commit comments

Comments
 (0)