@@ -341,10 +341,11 @@ bytesRead = 0; goto input; } if (!SSL_is_init_finished(statePtr->ssl)) { + dprintf("Calling Tls_WaitForConnect"); bytesRead = Tls_WaitForConnect(statePtr, errorCodePtr); if (bytesRead <= 0) { dprintf("Got an error (bytesRead = %i)", bytesRead); if (*errorCodePtr == ECONNRESET) { @@ -435,10 +436,11 @@ *errorCodePtr = EAGAIN; goto output; } if (!SSL_is_init_finished(statePtr->ssl)) { + dprintf("Calling Tls_WaitForConnect"); written = Tls_WaitForConnect(statePtr, errorCodePtr); if (written <= 0) { dprintf("Tls_WaitForConnect returned %i (err = %i)", written, *errorCodePtr); goto output; @@ -739,21 +741,25 @@ Tcl_DeleteTimerHandler(statePtr->timer); statePtr->timer = (Tcl_TimerToken) NULL; } if (statePtr->flags & TLS_TCL_CALLBACK) { + dprintf("Returning 0 due to callback"); return 0; } - if (statePtr->flags & TLS_TCL_INIT - && !SSL_is_init_finished(statePtr->ssl)) { + if ((statePtr->flags & TLS_TCL_INIT) && !SSL_is_init_finished(statePtr->ssl)) { int errorCode = 0; + + dprintf("Calling Tls_WaitForConnect"); if (Tls_WaitForConnect(statePtr, &errorCode) <= 0 && errorCode == EAGAIN) { - dprintf("Async flag could be set (didn't check) and errorCode == EAGAIN"); + dprintf("Async flag could be set (didn't check) and errorCode == EAGAIN: Returning 0"); return 0; } } + + dprintf("Returning %i", mask); return mask; } /* @@ -940,11 +946,11 @@ *errorCodePtr = EAGAIN; return -1; } else { continue; } - } else if (err == 0) { + } else if (err <= 0) { if (SSL_in_init(statePtr->ssl)) { dprintf("SSL_in_init() is true"); } if (Tcl_Eof(statePtr->self)) { @@ -954,10 +960,11 @@ dprintf("Error from some reason other than our BIO, returning 0"); return 0; } } dprintf("CR! "); + statePtr->flags |= TLS_TCL_HANDSHAKE_FAILED; *errorCodePtr = ECONNRESET; return -1; } if (statePtr->flags & TLS_TCL_SERVER) { err = SSL_get_verify_result(statePtr->ssl);