Tcl Source Code

Check-in [2786a736bc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:proposed solution for bug-510001
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | bug-510001
Files: files | file ages | folders
SHA1: 2786a736bcb251a7277fabf88ea91d30fa6a9494
User & Date: jan.nijtmans 2012-03-29 10:21:11
Context
2012-03-29
10:21
proposed solution for bug-510001 Closed-Leaf check-in: 2786a736bc user: jan.nijtmans tags: bug-510001
07:26
now ready for further field tests Closed-Leaf check-in: 5064618d7f user: jan.nijtmans tags: bug-3511806
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclIOSock.c.

79
80
81
82
83
84
85


86
87
88
89
90
91
92
 *
 * Side effects:
 *	Sets SO_SNDBUF and SO_RCVBUF sizes.
 *
 *----------------------------------------------------------------------
 */



int
TclSockMinimumBuffers(sock, size)
    int sock;			/* Socket file descriptor */
    int size;			/* Minimum buffer size */
{
    int current;
    socklen_t len;







>
>







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
 *
 * Side effects:
 *	Sets SO_SNDBUF and SO_RCVBUF sizes.
 *
 *----------------------------------------------------------------------
 */

#ifndef _WIN64
/* On WIN64 the signature is wrong, see bug 510001 */
int
TclSockMinimumBuffers(sock, size)
    int sock;			/* Socket file descriptor */
    int size;			/* Minimum buffer size */
{
    int current;
    socklen_t len;
101
102
103
104
105
106
107


    getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&current, &len);
    if (current < size) {
	len = sizeof(int);
	setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&size, len);
    }
    return TCL_OK;
}









>
>
103
104
105
106
107
108
109
110
111
    getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&current, &len);
    if (current < size) {
	len = sizeof(int);
	setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&size, len);
    }
    return TCL_OK;
}
#endif /* !_WIN64 */

Changes to generic/tclIntDecls.h.

1404
1405
1406
1407
1408
1409
1410





1411
1412
#define TclMatchIsTrivial \
	(tclIntStubsPtr->tclMatchIsTrivial) /* 199 */
#endif

#endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */

/* !END!: Do not edit above this line. */






#endif /* _TCLINTDECLS */







>
>
>
>
>


1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
#define TclMatchIsTrivial \
	(tclIntStubsPtr->tclMatchIsTrivial) /* 199 */
#endif

#endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */

/* !END!: Do not edit above this line. */

#ifdef _WIN64
/* See bug 510001: TclSockMinimumBuffers needs plat imp */
#   undef TclSockMinimumBuffers
#endif

#endif /* _TCLINTDECLS */

Changes to generic/tclStubInit.c.

50
51
52
53
54
55
56




57
58
59
60
61
62
63
    NULL,
#endif
    NULL,
    NULL,
    NULL,
    NULL
};





#ifdef __CYGWIN__

#define TclWinGetPlatformId winGetPlatformId
#define Tcl_WinUtfToTChar winUtfToTChar
#define Tcl_WinTCharToUtf winTCharToUtf
#define TclWinGetTclInstance winGetTclInstance







>
>
>
>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    NULL,
#endif
    NULL,
    NULL,
    NULL,
    NULL
};

#ifdef _WIN64
#define TclSockMinimumBuffers 0
#endif

#ifdef __CYGWIN__

#define TclWinGetPlatformId winGetPlatformId
#define Tcl_WinUtfToTChar winUtfToTChar
#define Tcl_WinTCharToUtf winTCharToUtf
#define TclWinGetTclInstance winGetTclInstance

Changes to win/tclWinSock.c.

1081
1082
1083
1084
1085
1086
1087











































1088
1089
1090
1091
1092
1093
1094
    
    return infoPtr;
}

/*
 *----------------------------------------------------------------------
 *











































 * CreateSocket --
 *
 *	This function opens a new socket and initializes the
 *	SocketInfo structure.
 *
 * Results:
 *	Returns a new SocketInfo, or NULL with an error in interp.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
    
    return infoPtr;
}

/*
 *----------------------------------------------------------------------
 *
 * TclSockMinimumBuffers --
 *
 *	Ensure minimum buffer sizes (non zero).
 *
 * Results:
 *	A standard Tcl result.
 *
 * Side effects:
 *	Sets SO_SNDBUF and SO_RCVBUF sizes.
 *
 *----------------------------------------------------------------------
 */

#ifdef _WIN64
/* On WIN64 the signature is wrong, see bug 510001 */
#define TclSockMinimumBuffers sockMinimumBuffers
static int
TclSockMinimumBuffers(sock, size)
    SOCKET sock;			/* Socket file descriptor */
    int size;			/* Minimum buffer size */
{
    int current;
    socklen_t len;

    len = sizeof(int);
    TclWinGetSockOpt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&current, &len);
    if (current < size) {
	len = sizeof(int);
	TclWinSetSockOpt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&size, len);
    }
    len = sizeof(int);
    TclWinGetSockOpt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&current, &len);
    if (current < size) {
	len = sizeof(int);
	TclWinSetSockOpt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&size, len);
    }
    return TCL_OK;
}
#endif /* !_WIN64 */

/*
 *----------------------------------------------------------------------
 *
 * CreateSocket --
 *
 *	This function opens a new socket and initializes the
 *	SocketInfo structure.
 *
 * Results:
 *	Returns a new SocketInfo, or NULL with an error in interp.
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166

    SetHandleInformation( (HANDLE) sock, HANDLE_FLAG_INHERIT, 0 );
	
    /*
     * Set kernel space buffering
     */

    TclSockMinimumBuffers((int) sock, TCP_BUFFER_SIZE);

    if (server) {
	/*
	 * Bind to the specified port.  Note that we must not call setsockopt
	 * with SO_REUSEADDR because Microsoft allows addresses to be reused
	 * even if they are still in use.
         *







|







1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209

    SetHandleInformation( (HANDLE) sock, HANDLE_FLAG_INHERIT, 0 );
	
    /*
     * Set kernel space buffering
     */

    TclSockMinimumBuffers(sock, TCP_BUFFER_SIZE);

    if (server) {
	/*
	 * Bind to the specified port.  Note that we must not call setsockopt
	 * with SO_REUSEADDR because Microsoft allows addresses to be reused
	 * even if they are still in use.
         *
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527

    tsdPtr = (ThreadSpecificData *)TclThreadDataKeyGet(&dataKey);

    /*
     * Set kernel space buffering and non-blocking.
     */

    TclSockMinimumBuffers((int) sock, TCP_BUFFER_SIZE);

    infoPtr = NewSocketInfo((SOCKET) sock);

    /*
     * Start watching for read/write events on the socket.
     */








|







1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570

    tsdPtr = (ThreadSpecificData *)TclThreadDataKeyGet(&dataKey);

    /*
     * Set kernel space buffering and non-blocking.
     */

    TclSockMinimumBuffers(sock, TCP_BUFFER_SIZE);

    infoPtr = NewSocketInfo((SOCKET) sock);

    /*
     * Start watching for read/write events on the socket.
     */