@@ -158,24 +158,24 @@ * Side effects: * Closes the socket of the channel. * *------------------------------------------------------------------- */ -static int -TlsCloseProc(ClientData instanceData, /* The socket to close. */ - Tcl_Interp *interp) /* For error reporting - unused. */ -{ - State *statePtr = (State *) instanceData; - - dprintf("TlsCloseProc(%p)", (void *) statePtr); - - Tls_Clean(statePtr); - Tcl_EventuallyFree((ClientData)statePtr, Tls_Free); - - dprintf("Returning TCL_OK"); - - return TCL_OK; +static int TlsCloseProc(ClientData instanceData, Tcl_Interp *interp) { + State *statePtr = (State *) instanceData; + + dprintf("TlsCloseProc(%p)", (void *) statePtr); + + Tls_Clean(statePtr); + Tcl_EventuallyFree((ClientData)statePtr, Tls_Free); + + dprintf("Returning TCL_OK"); + + return(TCL_OK); + + /* Interp is unused. */ + interp = interp; } /* *------------------------------------------------------------------- * @@ -265,11 +265,11 @@ dprintf("I/O error reading, treating it as EOF"); *errorCodePtr = 0; bytesRead = 0; break; } -input: + dprintf("Input(%d) -> %d [%d]", bufSize, bytesRead, *errorCodePtr); return bytesRead; } /* @@ -314,11 +314,20 @@ return(-1); } if (toWrite == 0) { dprintf("zero-write"); - BIO_flush(statePtr->bio); + err = BIO_flush(statePtr->bio); + + if (err <= 0) { + dprintf("Flushing failed"); + + *errorCodePtr = EIO; + written = 0; + return(-1); + } + written = 0; *errorCodePtr = 0; return(0); } @@ -369,11 +378,11 @@ break; default: dprintf(" unknown err: %d", err); break; } -output: + dprintf("Output(%d) -> %d", toWrite, written); return(written); } /* @@ -775,11 +784,15 @@ } if (err > 0) { dprintf("That seems to have gone okay"); - BIO_flush(statePtr->bio); + err = BIO_flush(statePtr->bio); + + if (err <= 0) { + dprintf("Flushing the lower layers failed, this will probably terminate this session"); + } } rc = SSL_get_error(statePtr->ssl, err); dprintf("Got error: %i (rc = %i)", err, rc);