summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2014-03-03 15:57:56 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2014-03-03 15:57:56 (GMT)
commitd2d1d997780ab3a1651986fc9820fd4a75ea8e56 (patch)
tree5e2de7b6886880ad96f6b0dfd327ad2529ffe1e6 /win
parent4dd180a450af9fce8d8128ebc37dfe3aa3932c6e (diff)
downloadtcl-d2d1d997780ab3a1651986fc9820fd4a75ea8e56.zip
tcl-d2d1d997780ab3a1651986fc9820fd4a75ea8e56.tar.gz
tcl-d2d1d997780ab3a1651986fc9820fd4a75ea8e56.tar.bz2
WIP: async open event now passes to SocketEventProc() and connects but does not finalyze that (I guess).
Diffstat (limited to 'win')
-rw-r--r--win/tclWinSock.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 905297e..ccae931 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -681,7 +681,10 @@ SocketCheckProc(
for (infoPtr = tsdPtr->socketList; infoPtr != NULL;
infoPtr = infoPtr->nextPtr) {
if ((infoPtr->readyEvents & infoPtr->watchEvents)
- && !(infoPtr->flags & SOCKET_PENDING)) {
+ && !(infoPtr->flags & SOCKET_PENDING)
+ || ( infoPtr->flags & SOCKET_ASYNC_CONNECT )
+ && ( infoPtr->readyEvents & FD_CONNECT )
+ ) {
infoPtr->flags |= SOCKET_PENDING;
evPtr = ckalloc(sizeof(SocketEvent));
evPtr->header.proc = SocketEventProc;
@@ -875,7 +878,7 @@ SocketEventProc(
if (events & FD_WRITE) {
mask |= TCL_WRITABLE;
}
- if (events & FD_CONNECT) {
+ if (infoPtr->readyEvents & FD_CONNECT) {
DEBUG("Calling CreateClientSocket...");
CreateClientSocket(NULL, infoPtr);
}
@@ -1236,12 +1239,24 @@ CreateClientSocket(
/*
* Set the socket into nonblocking mode if the connect should
* be done in the background.
+ * Activate notification for a connect.
*/
- if (async && ioctlsocket(infoPtr->sockets->fd, (long) FIONBIO, &flag)
- == SOCKET_ERROR) {
- DEBUG("FIONBIO");
- TclWinConvertError((DWORD) WSAGetLastError());
- continue;
+ if (async) {
+ if (ioctlsocket(infoPtr->sockets->fd, (long) FIONBIO, &flag)
+ == SOCKET_ERROR) {
+ DEBUG("FIONBIO");
+ TclWinConvertError((DWORD) WSAGetLastError());
+ continue;
+ }
+ {
+ ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey);
+ infoPtr->flags |= SOCKET_ASYNC_CONNECT;
+ infoPtr->selectEvents |= FD_CONNECT;
+
+ ioctlsocket(infoPtr->sockets->fd, (long) FIONBIO, &flag);
+ SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
+ (LPARAM) infoPtr);
+ }
}
/*
@@ -1256,15 +1271,8 @@ CreateClientSocket(
#ifdef DEBUGGING
// fprintf(stderr,"error = %lu\n", error);
#endif
- if (error == WSAEWOULDBLOCK) {
- ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey);
+ if (async && error == WSAEWOULDBLOCK) {
DEBUG("WSAEWOULDBLOCK");
- infoPtr->flags |= SOCKET_ASYNC_CONNECT;
- infoPtr->selectEvents |= FD_CONNECT;
-
- ioctlsocket(infoPtr->sockets->fd, (long) FIONBIO, &flag);
- SendMessage(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) SELECT,
- (LPARAM) infoPtr);
return TCL_OK;
} else {
DEBUG("ELSE");