14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
-
|
* Also work done by the follow people provided the impetus to do this "right":
* tclSSL (Colin McCormack, Shared Technology)
* SSLtcl (Peter Antman)
*
*/
#include "tlsInt.h"
#include <errno.h>
/*
* Forward declarations
*/
static void TlsChannelHandlerTimer(void *clientData);
/*
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
-
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
-
+
|
}
return(0);
}
/*
*-------------------------------------------------------------------
*
* 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.
*
* Note: we leave the underlying socket alone, is this right?
*
* Results:
* 0 if successful or POSIX error code if failed.
*
* 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;
dprintf("TlsCloseProc(%p)", statePtr);
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 */
{
State *statePtr = (State *)instanceData;
dprintf("TlsClose2Proc(%p)", instanceData);
dprintf("TlsClose2Proc(%p)", statePtr);
if (!(flags & (TCL_CLOSE_READ|TCL_CLOSE_WRITE))) {
return TlsCloseProc(instanceData, interp);
if ((flags&(TCL_CLOSE_READ|TCL_CLOSE_WRITE))) {
return EINVAL;
}
Tls_Clean(statePtr);
Tcl_EventuallyFree(statePtr, Tls_Free);
return EINVAL;
return TCL_OK;
}
/*
*------------------------------------------------------*
*
* Tls_WaitForConnect --
*
|
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
|
765
766
767
768
769
770
771
772
773
774
775
776
777
778
|
-
|
* to. But this transformation has no such interest. It just passes
* the request down, unchanged.
*/
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");
Tcl_DeleteTimerHandler(statePtr->timer);
statePtr->timer = (Tcl_TimerToken) NULL;
|
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
|
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
|
-
+
|
*
* Result:
* None.
*
*------------------------------------------------------*
*/
static void TlsChannelHandlerTimer(void *clientData) {
State *statePtr = (State *) clientData;
State *statePtr = (State *)clientData;
int mask = 0;
dprintf("Called");
statePtr->timer = (Tcl_TimerToken) NULL;
if (BIO_wpending(statePtr->bio)) {
|
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
|
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
|
-
+
|
Tcl_Channel Tls_GetParent(State *statePtr, int maskFlags) {
dprintf("Requested to get parent of channel %p", statePtr->self);
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);
}
/*
*-------------------------------------------------------------------
*
* Tls_ChannelType --
*
|