Check-in [b3abc0c1c4]
Bounty program for improvements to Tcl and certain Tcl packages.
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  +2000-06-05  Brent Welch <[email protected]>
            2  +
            3  +	* tls.c, tlsIO.c:  Split Tls_Free into Tls_Clean, which does
            4  +	the SSL cleanup, and the Tcl_Free call.  It is important to shutdown
            5  +	the SSL state "synchronously" during a stacked flush.
            6  +
     1      7   2000-06-01  Scott Stanton  <[email protected]>
     2      8   
     3      9   	* tlsIO.c: Restored call to Tcl_NotifyChannel from ChannelHandler
     4     10   	to ensure that events propagate from the lower driver.  This may
     5     11   	result in an infinite loop in some cases, so this is not a total
     6     12   	fix.  This may be sufficient for now, however. [Bug: 5623]
     7     13   

Modified tls.c from [58fc6e64f6] to [574ea1f12d].

     1      1   /*
     2      2    * Copyright (C) 1997-1999 Matt Newman <[email protected]>
     3      3    *
     4         - * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.c,v 1.3 2000/05/04 20:40:40 aborr Exp $
            4  + * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.c,v 1.4 2000/06/05 18:09:53 welch Exp $
     5      5    *
     6      6    * TLS (aka SSL) Channel - can be layered on any bi-directional
     7      7    * Tcl_Channel (Note: Requires Trf Core Patch)
     8      8    *
     9      9    * This was built (almost) from scratch based upon observation of
    10     10    * OpenSSL 0.9.2B
    11     11    *
................................................................................
   724    724   			       (TCL_READABLE | TCL_WRITABLE), statePtr->parent);
   725    725   #else
   726    726       statePtr->self = chan;
   727    727       Tcl_StackChannel( interp, Tls_ChannelType(), (ClientData) statePtr,
   728    728   			       (TCL_READABLE | TCL_WRITABLE), chan);
   729    729   #endif
   730    730       if (statePtr->self == (Tcl_Channel) NULL) {
   731         -        Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free);
          731  +	Tls_Free(statePtr);
          732  +/*        Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free); */
   732    733           return TCL_ERROR;
   733    734       }
   734    735   
   735    736       /* allocate script */
   736    737       if (script) {
   737    738   	char * tmp = Tcl_GetStringFromObj(script, NULL);
   738    739   	if (tmp && *tmp) {
................................................................................
   752    753   
   753    754       statePtr->ssl = SSL_new(statePtr->ctx);
   754    755       if (!statePtr->ssl) {
   755    756           /* SSL library error */
   756    757           Tcl_AppendResult(interp,
   757    758                            "couldn't construct ssl session: ", REASON(),
   758    759                            (char *) NULL);
   759         -        Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free);
          760  +	Tls_Free(statePtr);
          761  +/*        Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free); */
   760    762           return TCL_ERROR;
   761    763       }
   762    764   
   763    765       /*
   764    766        * SSL Callbacks
   765    767        */
   766    768   
................................................................................
  1027   1029    *-------------------------------------------------------------------
  1028   1030    */
  1029   1031   void
  1030   1032   Tls_Free( char *blockPtr )
  1031   1033   {
  1032   1034       State *statePtr = (State *)blockPtr;
  1033   1035   
         1036  +    Tls_Clean(blockPtr);
         1037  +    Tcl_Free((char *)statePtr);
         1038  +}
         1039  +
         1040  +/*
         1041  + *-------------------------------------------------------------------
         1042  + *
         1043  + * Tls_Clean --
         1044  + *
         1045  + *	This procedure cleans up when a SSL socket based channel
         1046  + *	is closed and its reference count falls below 1.  This should
         1047  + *	be called synchronously by the CloseProc, not in the
         1048  + *	EventuallyFree callback.
         1049  + *
         1050  + * Results:
         1051  + *	none
         1052  + *
         1053  + * Side effects:
         1054  + *	Frees all the state
         1055  + *
         1056  + *-------------------------------------------------------------------
         1057  + */
         1058  +void
         1059  +Tls_Clean( char *blockPtr )
         1060  +{
         1061  +    State *statePtr = (State *)blockPtr;
         1062  +
  1034   1063       /* we're assuming here that we're single-threaded */
  1035   1064       if (statePtr->ssl) {
  1036   1065   	SSL_shutdown(statePtr->ssl);
  1037   1066   	SSL_free(statePtr->ssl);
         1067  +	statePtr->ssl = NULL;
  1038   1068       }
  1039         -    if (statePtr->callback)
         1069  +    if (statePtr->callback) {
  1040   1070   	Tcl_DecrRefCount(statePtr->callback);
  1041         -
  1042         -    if (statePtr->timer != (Tcl_TimerToken)NULL)
  1043         -	Tcl_DeleteTimerHandler (statePtr->timer);
         1071  +	statePtr->callback = NULL;
         1072  +    }
  1044   1073   
  1045         -    Tcl_Free((char *)statePtr);
         1074  +    if (statePtr->timer != (Tcl_TimerToken)NULL) {
         1075  +	Tcl_DeleteTimerHandler (statePtr->timer);
         1076  +	statePtr->timer = NULL;
         1077  +    }
         1078  +
  1046   1079   }
  1047   1080   
  1048   1081   /*
  1049   1082    *-------------------------------------------------------------------
  1050   1083    *
  1051   1084    * Tls_Init --
  1052   1085    *

Modified tlsIO.c from [917446d5a9] to [83d2c33ca1].

     1      1   /*
     2      2    * Copyright (C) 1997-2000 Matt Newman <[email protected]>
     3      3    *
     4         - * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tlsIO.c,v 1.6 2000/06/02 05:14:46 welch Exp $
            4  + * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tlsIO.c,v 1.7 2000/06/05 18:09:54 welch Exp $
     5      5    *
     6      6    * TLS (aka SSL) Channel - can be layered on any bi-directional
     7      7    * Tcl_Channel (Note: Requires Trf Core Patch)
     8      8    *
     9      9    * This was built from scratch based upon observation of OpenSSL 0.9.2B
    10     10    *
    11     11    * Addition credit is due for Andreas Kupries ([email protected]), for
................................................................................
   138    138   	ChannelHandler, (ClientData) statePtr);
   139    139   
   140    140       if (statePtr->timer != (Tcl_TimerToken)NULL) {
   141    141   	Tcl_DeleteTimerHandler (statePtr->timer);
   142    142   	statePtr->timer = (Tcl_TimerToken)NULL;
   143    143       }
   144    144   
          145  +    Tls_Clean(statePtr);
   145    146       Tcl_EventuallyFree( (ClientData)statePtr, Tls_Free);
   146    147       return TCL_OK;
   147    148   }
   148    149   
   149    150   /*
   150    151    *-------------------------------------------------------------------
   151    152    *