@@ -16,11 +16,10 @@ * SSLtcl (Peter Antman) * */ #include "tlsInt.h" -#include /* * Forward declarations */ static void TlsChannelHandlerTimer(void *clientData); @@ -53,11 +52,11 @@ } /* *------------------------------------------------------------------- * - * TlsCloseProc -- + * TlsClose2Proc -- * * This procedure is invoked by the generic IO level to perform * channel-type-specific cleanup when a SSL socket based channel * is closed. * @@ -69,10 +68,13 @@ * Side effects: * Closes the socket of the channel. * *------------------------------------------------------------------- */ +#if TCL_MAJOR_VERSION > 8 +# define TlsCloseProc NULL /* No longer neccessary in Tcl 9 */ +#else static int TlsCloseProc( void *instanceData, TCL_UNUSED(Tcl_Interp *)) { State *statePtr = (State *)instanceData; @@ -81,22 +83,27 @@ Tls_Clean(statePtr); Tcl_EventuallyFree(statePtr, Tls_Free); return TCL_OK; } +#endif static int TlsClose2Proc( void *instanceData, /* The socket state. */ Tcl_Interp *interp, /* For errors - can be NULL. */ int flags) /* Flags to close read and/or write side of channel */ { - dprintf("TlsClose2Proc(%p)", instanceData); + State *statePtr = (State *)instanceData; - if (!(flags & (TCL_CLOSE_READ|TCL_CLOSE_WRITE))) { - return TlsCloseProc(instanceData, interp); + dprintf("TlsClose2Proc(%p)", statePtr); + + if ((flags&(TCL_CLOSE_READ|TCL_CLOSE_WRITE))) { + return EINVAL; } - return EINVAL; + Tls_Clean(statePtr); + Tcl_EventuallyFree(statePtr, Tls_Free); + return TCL_OK; } /* *------------------------------------------------------* * @@ -760,11 +767,10 @@ */ dprintf("Registering our interest in the lower channel (chan=%p)", (void *) downChan); watchProc = Tcl_ChannelWatchProc(Tcl_GetChannelType(downChan)); watchProc(Tcl_GetChannelInstanceData(downChan), mask); - /* * Management of the internal timer. */ if (statePtr->timer != (Tcl_TimerToken) NULL) { dprintf("A timer was found, deleting it"); @@ -891,11 +897,11 @@ * None. * *------------------------------------------------------* */ static void TlsChannelHandlerTimer(void *clientData) { - State *statePtr = (State *) clientData; + State *statePtr = (State *)clientData; int mask = 0; dprintf("Called"); statePtr->timer = (Tcl_TimerToken) NULL; @@ -925,11 +931,11 @@ if ((statePtr->flags & ~maskFlags) & TLS_TCL_FASTPATH) { dprintf("Asked to get the parent channel while we are using FastPath -- returning NULL"); return(NULL); } - return(Tcl_GetStackedChannel(statePtr->self)); + return Tcl_GetStackedChannel(statePtr->self); } /* *------------------------------------------------------------------- *