Check-in [b3abc0c1c4]
Overview
Comment:Moved SSL shutdown up into the CloseProc, away from the asynchronous EventuallyFree
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b3abc0c1c474b5b2ea14e4f8d59785e0a518aec0
User & Date: welch on 2000-06-05 18:09:53
Other Links: manifest | tags
Context
2000-06-05
20:20
changed generation of pkgIndex file for test target check-in: 24a46987ec user: aborr tags: trunk
18:09
Moved SSL shutdown up into the CloseProc, away from the asynchronous EventuallyFree check-in: b3abc0c1c4 user: welch tags: trunk
2000-06-03
05:01
More test fixes. Tests marked "empty" will hang, presumably because of the synchronous nature of those tests. check-in: 2af1d4883b user: awb tags: trunk
Changes
Modified ChangeLog from [5ef64b5c12] to [8f015c6d0b].






1
2
3
4
5
6
7






2000-06-01  Scott Stanton  <stanton@ajubasolutions.com>

	* tlsIO.c: Restored call to Tcl_NotifyChannel from ChannelHandler
	to ensure that events propagate from the lower driver.  This may
	result in an infinite loop in some cases, so this is not a total
	fix.  This may be sufficient for now, however. [Bug: 5623]

>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
2000-06-05  Brent Welch <welch@ajubasolutions.com>

	* tls.c, tlsIO.c:  Split Tls_Free into Tls_Clean, which does
	the SSL cleanup, and the Tcl_Free call.  It is important to shutdown
	the SSL state "synchronously" during a stacked flush.

2000-06-01  Scott Stanton  <stanton@ajubasolutions.com>

	* tlsIO.c: Restored call to Tcl_NotifyChannel from ChannelHandler
	to ensure that events propagate from the lower driver.  This may
	result in an infinite loop in some cases, so this is not a total
	fix.  This may be sufficient for now, however. [Bug: 5623]

Modified tls.c from [58fc6e64f6] to [574ea1f12d].
1
2
3
4
5
6
7
8
9
10
11
/*
 * Copyright (C) 1997-1999 Matt Newman <matt@novadigm.com>
 *
 * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.c,v 1.3 2000/05/04 20:40:40 aborr Exp $
 *
 * TLS (aka SSL) Channel - can be layered on any bi-directional
 * Tcl_Channel (Note: Requires Trf Core Patch)
 *
 * This was built (almost) from scratch based upon observation of
 * OpenSSL 0.9.2B
 *



|







1
2
3
4
5
6
7
8
9
10
11
/*
 * Copyright (C) 1997-1999 Matt Newman <matt@novadigm.com>
 *
 * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.c,v 1.4 2000/06/05 18:09:53 welch Exp $
 *
 * TLS (aka SSL) Channel - can be layered on any bi-directional
 * Tcl_Channel (Note: Requires Trf Core Patch)
 *
 * This was built (almost) from scratch based upon observation of
 * OpenSSL 0.9.2B
 *
724
725
726
727
728
729
730

731
732
733
734
735
736
737
738
			       (TCL_READABLE | TCL_WRITABLE), statePtr->parent);
#else
    statePtr->self = chan;
    Tcl_StackChannel( interp, Tls_ChannelType(), (ClientData) statePtr,
			       (TCL_READABLE | TCL_WRITABLE), chan);
#endif
    if (statePtr->self == (Tcl_Channel) NULL) {

        Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free);
        return TCL_ERROR;
    }

    /* allocate script */
    if (script) {
	char * tmp = Tcl_GetStringFromObj(script, NULL);
	if (tmp && *tmp) {







>
|







724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
			       (TCL_READABLE | TCL_WRITABLE), statePtr->parent);
#else
    statePtr->self = chan;
    Tcl_StackChannel( interp, Tls_ChannelType(), (ClientData) statePtr,
			       (TCL_READABLE | TCL_WRITABLE), chan);
#endif
    if (statePtr->self == (Tcl_Channel) NULL) {
	Tls_Free(statePtr);
/*        Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free); */
        return TCL_ERROR;
    }

    /* allocate script */
    if (script) {
	char * tmp = Tcl_GetStringFromObj(script, NULL);
	if (tmp && *tmp) {
752
753
754
755
756
757
758

759
760
761
762
763
764
765
766

    statePtr->ssl = SSL_new(statePtr->ctx);
    if (!statePtr->ssl) {
        /* SSL library error */
        Tcl_AppendResult(interp,
                         "couldn't construct ssl session: ", REASON(),
                         (char *) NULL);

        Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free);
        return TCL_ERROR;
    }

    /*
     * SSL Callbacks
     */








>
|







753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768

    statePtr->ssl = SSL_new(statePtr->ctx);
    if (!statePtr->ssl) {
        /* SSL library error */
        Tcl_AppendResult(interp,
                         "couldn't construct ssl session: ", REASON(),
                         (char *) NULL);
	Tls_Free(statePtr);
/*        Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free); */
        return TCL_ERROR;
    }

    /*
     * SSL Callbacks
     */

1027
1028
1029
1030
1031
1032
1033



























1034
1035
1036
1037

1038
1039
1040

1041

1042
1043

1044
1045
1046
1047
1048
1049
1050
1051
1052
 *-------------------------------------------------------------------
 */
void
Tls_Free( char *blockPtr )
{
    State *statePtr = (State *)blockPtr;




























    /* we're assuming here that we're single-threaded */
    if (statePtr->ssl) {
	SSL_shutdown(statePtr->ssl);
	SSL_free(statePtr->ssl);

    }
    if (statePtr->callback)
	Tcl_DecrRefCount(statePtr->callback);



    if (statePtr->timer != (Tcl_TimerToken)NULL)
	Tcl_DeleteTimerHandler (statePtr->timer);


    Tcl_Free((char *)statePtr);
}

/*
 *-------------------------------------------------------------------
 *
 * Tls_Init --
 *







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




>

|

>
|
>
|

>
|
|







1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
 *-------------------------------------------------------------------
 */
void
Tls_Free( char *blockPtr )
{
    State *statePtr = (State *)blockPtr;

    Tls_Clean(blockPtr);
    Tcl_Free((char *)statePtr);
}

/*
 *-------------------------------------------------------------------
 *
 * Tls_Clean --
 *
 *	This procedure cleans up when a SSL socket based channel
 *	is closed and its reference count falls below 1.  This should
 *	be called synchronously by the CloseProc, not in the
 *	EventuallyFree callback.
 *
 * Results:
 *	none
 *
 * Side effects:
 *	Frees all the state
 *
 *-------------------------------------------------------------------
 */
void
Tls_Clean( char *blockPtr )
{
    State *statePtr = (State *)blockPtr;

    /* we're assuming here that we're single-threaded */
    if (statePtr->ssl) {
	SSL_shutdown(statePtr->ssl);
	SSL_free(statePtr->ssl);
	statePtr->ssl = NULL;
    }
    if (statePtr->callback) {
	Tcl_DecrRefCount(statePtr->callback);
	statePtr->callback = NULL;
    }

    if (statePtr->timer != (Tcl_TimerToken)NULL) {
	Tcl_DeleteTimerHandler (statePtr->timer);
	statePtr->timer = NULL;
    }

}

/*
 *-------------------------------------------------------------------
 *
 * Tls_Init --
 *
Modified tlsIO.c from [917446d5a9] to [83d2c33ca1].
1
2
3
4
5
6
7
8
9
10
11
/*
 * Copyright (C) 1997-2000 Matt Newman <matt@novadigm.com>
 *
 * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tlsIO.c,v 1.6 2000/06/02 05:14:46 welch Exp $
 *
 * TLS (aka SSL) Channel - can be layered on any bi-directional
 * Tcl_Channel (Note: Requires Trf Core Patch)
 *
 * This was built from scratch based upon observation of OpenSSL 0.9.2B
 *
 * Addition credit is due for Andreas Kupries (a.kupries@westend.com), for



|







1
2
3
4
5
6
7
8
9
10
11
/*
 * Copyright (C) 1997-2000 Matt Newman <matt@novadigm.com>
 *
 * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tlsIO.c,v 1.7 2000/06/05 18:09:54 welch Exp $
 *
 * TLS (aka SSL) Channel - can be layered on any bi-directional
 * Tcl_Channel (Note: Requires Trf Core Patch)
 *
 * This was built from scratch based upon observation of OpenSSL 0.9.2B
 *
 * Addition credit is due for Andreas Kupries (a.kupries@westend.com), for
138
139
140
141
142
143
144

145
146
147
148
149
150
151
	ChannelHandler, (ClientData) statePtr);

    if (statePtr->timer != (Tcl_TimerToken)NULL) {
	Tcl_DeleteTimerHandler (statePtr->timer);
	statePtr->timer = (Tcl_TimerToken)NULL;
    }


    Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free);
    return TCL_OK;
}

/*
 *-------------------------------------------------------------------
 *







>







138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
	ChannelHandler, (ClientData) statePtr);

    if (statePtr->timer != (Tcl_TimerToken)NULL) {
	Tcl_DeleteTimerHandler (statePtr->timer);
	statePtr->timer = (Tcl_TimerToken)NULL;
    }

    Tls_Clean(statePtr);
    Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free);
    return TCL_OK;
}

/*
 *-------------------------------------------------------------------
 *