Diff

Differences From Artifact [7f72e998da]:

To Artifact [504969653b]:


67
68
69
70
71
72
73
74
75

76
77
78
79
80
81
82
83
84
85
67
68
69
70
71
72
73


74



75
76
77
78
79
80
81







-
-
+
-
-
-







	Tcl_Channel chan;
	int ret;

	chan = Tls_GetParent((State *) BIO_get_data(bio));

	dprintf("BioWrite(%p, <buf>, %d) [%p]", (void *) bio, bufLen, (void *) chan);

	if (channelTypeVersion == TLS_CHANNEL_VERSION_2) {
		ret = Tcl_WriteRaw(chan, buf, bufLen);
	ret = Tcl_WriteRaw(chan, buf, bufLen);
	} else {
		ret = Tcl_Write(chan, buf, bufLen);
	}

	dprintf("[%p] BioWrite(%d) -> %d [%d.%d]", (void *) chan, bufLen, ret, Tcl_Eof(chan), Tcl_GetErrno());

	BIO_clear_flags(bio, BIO_FLAGS_WRITE | BIO_FLAGS_SHOULD_RETRY);

	if (ret == 0) {
		if (!Tcl_Eof(chan)) {
104
105
106
107
108
109
110
111
112

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

133
134
135
136
137
138
139
100
101
102
103
104
105
106


107



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131







-
-
+
-
-
-
















-
+








	dprintf("BioRead(%p, <buf>, %d) [%p]", (void *) bio, bufLen, (void *) chan);

	if (buf == NULL) {
		return 0;
	}

	if (channelTypeVersion == TLS_CHANNEL_VERSION_2) {
		ret = Tcl_ReadRaw(chan, buf, bufLen);
	ret = Tcl_ReadRaw(chan, buf, bufLen);
	} else {
		ret = Tcl_Read(chan, buf, bufLen);
	}

	tclEofChan = Tcl_Eof(chan);

	dprintf("[%p] BioRead(%d) -> %d [tclEof=%d; tclErrno=%d]", (void *) chan, bufLen, ret, tclEofChan, Tcl_GetErrno());

	BIO_clear_flags(bio, BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY);

	if (ret == 0) {
		if (!tclEofChan) {
			dprintf("Got 0 from Tcl_Read or Tcl_ReadRaw, and EOF is not set -- ret == -1 now");
			BIO_set_retry_read(bio);
			ret = -1;
		} else {
			dprintf("Got 0 from Tcl_Read or Tcl_ReadRaw, and EOF is set");
		}
	} else {
		dprintf("Got non-zero from Tcl_Read or Tcl_ReadRaw == ret == %i", ret);
		dprintf("Got non-zero from Tcl_Read or Tcl_ReadRaw; ret == %i", ret);
	}

	if (BIO_should_write(bio)) {
		BIO_set_retry_write(bio);
	}

	dprintf("BioRead(%p, <buf>, %d) [%p] returning %i", (void *) bio, bufLen, (void *) chan, ret);
153
154
155
156
157
158
159

160
161

162

163
164
165

166
167
168
169
170
171
172
173
174
175
176

177
178
179

180
181
182
183

184
185
186

187
188
189
190

191
192
193

194
195
196

197
198

199
200
201
202
203
204

205
206
207
208
209
210
211
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180

181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

197


198



199
200
201
202
203
204
205
206
207
208
209







+


+

+



+











+



+



-
+



+




+



+


-
+
-
-
+
-
-
-



+








	chan = Tls_GetParent((State *) BIO_get_data(bio));

	dprintf("BioCtrl(%p, 0x%x, 0x%x, %p)", (void *) bio, (unsigned int) cmd, (unsigned int) num, (void *) ptr);

	switch (cmd) {
		case BIO_CTRL_RESET:
			dprintf("Got BIO_CTRL_RESET");
			num = 0;
		case BIO_C_FILE_SEEK:
			dprintf("Got BIO_C_FILE_SEEK");
		case BIO_C_FILE_TELL:
			dprintf("Got BIO_C_FILE_TELL");
			ret = 0;
			break;
		case BIO_CTRL_INFO:
			dprintf("Got BIO_CTRL_INFO");
			ret = 1;
			break;
		case BIO_C_SET_FD:
			dprintf("Unsupported call: BIO_C_SET_FD");
			ret = -1;
			break;
		case BIO_C_GET_FD:
			dprintf("Unsupported call: BIO_C_GET_FD");
			ret = -1;
			break;
		case BIO_CTRL_GET_CLOSE:
			dprintf("Got BIO_CTRL_CLOSE");
			ret = BIO_get_shutdown(bio);
			break;
		case BIO_CTRL_SET_CLOSE:
			dprintf("Got BIO_SET_CLOSE");
			BIO_set_shutdown(bio, num);
			break;
		case BIO_CTRL_EOF:
			dprintf("BIO_CTRL_EOF");
			dprintf("Got BIO_CTRL_EOF");
			ret = Tcl_Eof(chan);
			break;
		case BIO_CTRL_PENDING:
			dprintf("Got BIO_CTRL_PENDING");
			ret = ((chan) ? 1 : 0);
			dprintf("BIO_CTRL_PENDING(%d)", (int) ret);
			break;
		case BIO_CTRL_WPENDING:
			dprintf("Got BIO_CTRL_WPENDING");
			ret = 0;
			break;
		case BIO_CTRL_DUP:
			dprintf("Got BIO_CTRL_DUP");
			break;
		case BIO_CTRL_FLUSH:
			dprintf("BIO_CTRL_FLUSH");
			dprintf("Got BIO_CTRL_FLUSH");
			if (channelTypeVersion == TLS_CHANNEL_VERSION_2) {
				ret = ((Tcl_WriteRaw(chan, "", 0) >= 0) ? 1 : -1);
			ret = ((Tcl_WriteRaw(chan, "", 0) >= 0) ? 1 : -1);
			} else {
				ret = ((Tcl_Flush(chan) == TCL_OK) ? 1 : -1);
			}
			dprintf("BIO_CTRL_FLUSH returning value %li", ret);
			break;
		default:
			dprintf("Got unknown control command (%i)", cmd);
			ret = 0;
			break;
	}

	return(ret);
}