Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Minor code improvement: combine "flags" and "testFlags" struct members to a single one. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | mistake |
Files: | files | file ages | folders |
SHA1: |
f1e67b2730f8ce2b60dd0a752bbcecbd |
User & Date: | jan.nijtmans 2014-07-17 12:49:20 |
Context
2014-07-17
| ||
12:54 | merge trunk Closed-Leaf check-in: 4be44a2039 user: jan.nijtmans tags: mistake | |
12:49 | Minor code improvement: combine "flags" and "testFlags" struct members to a single one. check-in: f1e67b2730 user: jan.nijtmans tags: mistake | |
09:53 | Replaced option "-unsupported1" by test command "testsocket debugflags" (thanks Donal, Donald). check-in: 33737f615b user: oehhar tags: robust-async-connect-tests | |
Changes
Changes to generic/tclTest.c.
︙ | ︙ | |||
79 80 81 82 83 84 85 | * Start of the socket driver state structure to acces field testFlags */ typedef struct TcpState TcpState; struct TcpState { Tcl_Channel channel; /* Channel associated with this socket. */ | | < | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | * Start of the socket driver state structure to acces field testFlags */ typedef struct TcpState TcpState; struct TcpState { Tcl_Channel channel; /* Channel associated with this socket. */ int flags; /* bit field for flags */ }; TCL_DECLARE_MUTEX(asyncTestMutex) static TestAsyncHandler *firstHandler = NULL; /* |
︙ | ︙ | |||
6039 6040 6041 6042 6043 6044 6045 | } statePtr = (TcpState *)Tcl_GetChannelInstanceData(hChannel); if ( NULL == statePtr) { Tcl_AppendResult(interp, "No channel instance data:", argv[2], NULL); return TCL_ERROR; } | | | 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 | } statePtr = (TcpState *)Tcl_GetChannelInstanceData(hChannel); if ( NULL == statePtr) { Tcl_AppendResult(interp, "No channel instance data:", argv[2], NULL); return TCL_ERROR; } statePtr->flags = (statePtr->flags&0xff) | (atoi(argv[3])<<8); return TCL_OK; } Tcl_AppendResult(interp, "bad option \"", cmdName, "\": should be " "testflags", NULL); return TCL_ERROR; } |
︙ | ︙ |
Changes to tests/socket.test.
︙ | ︙ | |||
2153 2154 2155 2156 2157 2158 2159 | vwait x list [fconfigure $sock -error] [gets $fd] } -cleanup { close $fd close $sock } -result {{} ok} test socket-14.11.0 {pending [socket -async] and nonblocking [puts], no listener, no flush} \ | | | 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 | vwait x list [fconfigure $sock -error] [gets $fd] } -cleanup { close $fd close $sock } -result {{} ok} test socket-14.11.0 {pending [socket -async] and nonblocking [puts], no listener, no flush} \ -constraints {socket} \ -body { set sock [socket -async localhost [randport]] fconfigure $sock -blocking 0 puts $sock ok fileevent $sock writable {set x 1} vwait x close $sock |
︙ | ︙ |
Changes to unix/tclUnixSock.c.
︙ | ︙ | |||
48 49 50 51 52 53 54 | TcpState *statePtr; int fd; struct TcpFdList *next; } TcpFdList; struct TcpState { Tcl_Channel channel; /* Channel associated with this file. */ | < < < > | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | TcpState *statePtr; int fd; struct TcpFdList *next; } TcpFdList; struct TcpState { Tcl_Channel channel; /* Channel associated with this file. */ int flags; /* ORed combination of the bitfields defined * below. */ TcpFdList fds; /* The file descriptors of the sockets. */ /* * Only needed for server sockets */ Tcl_TcpAcceptProc *acceptProc; /* Proc to call on accept. */ ClientData acceptProcData; /* The data for the accept proc. */ |
︙ | ︙ | |||
88 89 90 91 92 93 94 | #define TCP_ASYNC_CONNECT (1<<1) /* Async connect in progress. */ #define TCP_ASYNC_PENDING (1<<4) /* TcpConnect was called to * process an async connect. This * flag indicates that reentry is * still pending */ #define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */ | < < < < < | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | #define TCP_ASYNC_CONNECT (1<<1) /* Async connect in progress. */ #define TCP_ASYNC_PENDING (1<<4) /* TcpConnect was called to * process an async connect. This * flag indicates that reentry is * still pending */ #define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */ #define TCP_ASYNC_TEST_MODE (1<<8) /* Async testing activated * Do not automatically continue connection * process */ /* * The following defines the maximum length of the listen queue. This is the * number of outstanding yet-to-be-serviced requests for a connection on a * server socket, more than this number of outstanding requests and the |
︙ | ︙ | |||
454 455 456 457 458 459 460 | /* * In socket test mode do not continue with the connect * Exceptions are: * - Call by recv/send and blocking socket * (errorCodePtr != NULL && ! flags & TCP_NONBLOCKING) */ | | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | /* * In socket test mode do not continue with the connect * Exceptions are: * - Call by recv/send and blocking socket * (errorCodePtr != NULL && ! flags & TCP_NONBLOCKING) */ if ( (statePtr->flags & TCP_ASYNC_TEST_MODE) && ! (errorCodePtr != NULL && ! (statePtr->flags & TCP_NONBLOCKING))) { *errorCodePtr = EWOULDBLOCK; return -1; } if (errorCodePtr == NULL || (statePtr->flags & TCP_NONBLOCKING)) { timeout = 0; |
︙ | ︙ |
Changes to win/tclWinSock.c.
︙ | ︙ | |||
129 130 131 132 133 134 135 | TcpState *statePtr; SOCKET fd; struct TcpFdList *next; } TcpFdList; struct TcpState { Tcl_Channel channel; /* Channel associated with this socket. */ | < < < > | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | TcpState *statePtr; SOCKET fd; struct TcpFdList *next; } TcpFdList; struct TcpState { Tcl_Channel channel; /* Channel associated with this socket. */ int flags; /* Bit field comprised of the flags described * below. */ int watchEvents; /* OR'ed combination of FD_READ, FD_WRITE, * FD_CLOSE, FD_ACCEPT and FD_CONNECT that * indicate which events are interesting. */ volatile int readyEvents; /* OR'ed combination of FD_READ, FD_WRITE, * FD_CLOSE, FD_ACCEPT and FD_CONNECT that * indicate which events have occurred. * Set by notifier thread, access must be * protected by semaphore */ int selectEvents; /* OR'ed combination of FD_READ, FD_WRITE, * FD_CLOSE, FD_ACCEPT and FD_CONNECT that * indicate which events are currently being * selected. */ volatile int acceptEventCount; /* Count of the current number of FD_ACCEPTs * that have arrived and not yet processed. * Set by notifier thread, access must be * protected by semaphore */ struct TcpFdList *sockets; /* Windows SOCKET handle. */ Tcl_TcpAcceptProc *acceptProc; /* Proc to call on accept. */ ClientData acceptProcData; /* The data for the accept proc. */ /* * Only needed for client sockets */ |
︙ | ︙ | |||
190 191 192 193 194 195 196 | * socket */ #define TCP_ASYNC_PENDING (1<<4) /* TcpConnect was called to * process an async connect. This * flag indicates that reentry is * still pending */ #define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */ | < < < < < | | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | * socket */ #define TCP_ASYNC_PENDING (1<<4) /* TcpConnect was called to * process an async connect. This * flag indicates that reentry is * still pending */ #define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */ #define TCP_ASYNC_TEST_MODE (1<<8) /* Async testing activated * Do not automatically continue connection * process */ /* * The following structure is what is added to the Tcl event queue when a * socket event occurs. */ |
︙ | ︙ | |||
616 617 618 619 620 621 622 | * In socket test mode do not continue with the connect * Exceptions are: * - Call by recv/send and blocking socket * (errorCodePtr != NULL && ! flags & TCP_NONBLOCKING) * - Call by the event queue (errorCodePtr == NULL) */ | | | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | * In socket test mode do not continue with the connect * Exceptions are: * - Call by recv/send and blocking socket * (errorCodePtr != NULL && ! flags & TCP_NONBLOCKING) * - Call by the event queue (errorCodePtr == NULL) */ if ( (statePtr->flags & TCP_ASYNC_TEST_MODE) && errorCodePtr != NULL && (statePtr->flags & TCP_NONBLOCKING)) { *errorCodePtr = EWOULDBLOCK; return -1; } /* * Be sure to disable event servicing so we are truly modal. |
︙ | ︙ | |||
1275 1276 1277 1278 1279 1280 1281 | return TCL_ERROR; } /* * Go one step in async connect * If any error is thrown save it as backround error to report eventually below */ | | | 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 | return TCL_ERROR; } /* * Go one step in async connect * If any error is thrown save it as backround error to report eventually below */ if (! (statePtr->flags & TCP_ASYNC_TEST_MODE) ) { WaitForConnect(statePtr, NULL); } sock = statePtr->sockets->fd; if (optionName != NULL) { len = strlen(optionName); } |
︙ | ︙ |