Diff

Differences From Artifact [0f85acc9f6]:

To Artifact [f15c16a7e8]:


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
 *	0 if successful, the value of Tcl_GetErrno() if failed.
 *
 * Side effects:
 *	Closes the socket of the channel.
 *
 *-------------------------------------------------------------------
 */
static int
TlsCloseProc(ClientData instanceData,	/* The socket to close. */
             Tcl_Interp *interp)	/* For error reporting - unused. */
{
    State *statePtr = (State *) instanceData;

    dprintf("TlsCloseProc(%p)", (void *) statePtr);

    Tls_Clean(statePtr);
    Tcl_EventuallyFree((ClientData)statePtr, Tls_Free);

    dprintf("Returning TCL_OK");

    return TCL_OK;



}

/*
 *-------------------------------------------------------------------
 *
 * TlsInputProc --
 *







<
|
<
<
|

|

|
|

|

|
>
>
>







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
 *	0 if successful, the value of Tcl_GetErrno() if failed.
 *
 * Side effects:
 *	Closes the socket of the channel.
 *
 *-------------------------------------------------------------------
 */

static int TlsCloseProc(ClientData instanceData, Tcl_Interp *interp) {


	State *statePtr = (State *) instanceData;

	dprintf("TlsCloseProc(%p)", (void *) statePtr);

	Tls_Clean(statePtr);
	Tcl_EventuallyFree((ClientData)statePtr, Tls_Free);

	dprintf("Returning TCL_OK");

	return(TCL_OK);

	/* Interp is unused. */
	interp = interp;
}

/*
 *-------------------------------------------------------------------
 *
 * TlsInputProc --
 *
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
			break;
		case SSL_ERROR_SYSCALL:
			dprintf("I/O error reading, treating it as EOF");
			*errorCodePtr = 0;
			bytesRead = 0;
			break;
	}
input:
	dprintf("Input(%d) -> %d [%d]", bufSize, bytesRead, *errorCodePtr);
	return bytesRead;
}

/*
 *-------------------------------------------------------------------
 *







|







263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
			break;
		case SSL_ERROR_SYSCALL:
			dprintf("I/O error reading, treating it as EOF");
			*errorCodePtr = 0;
			bytesRead = 0;
			break;
	}

	dprintf("Input(%d) -> %d [%d]", bufSize, bytesRead, *errorCodePtr);
	return bytesRead;
}

/*
 *-------------------------------------------------------------------
 *
312
313
314
315
316
317
318
319









320
321
322
323
324
325
326
		dprintf("Tls_WaitForConnect returned %i (err = %i)", written, *errorCodePtr);

		return(-1);
	}

	if (toWrite == 0) {
		dprintf("zero-write");
		BIO_flush(statePtr->bio);









		written = 0;
		*errorCodePtr = 0;
		return(0);
	}

	/*
	 * We need to clear the SSL error stack now because we sometimes reach







|
>
>
>
>
>
>
>
>
>







312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
		dprintf("Tls_WaitForConnect returned %i (err = %i)", written, *errorCodePtr);

		return(-1);
	}

	if (toWrite == 0) {
		dprintf("zero-write");
		err = BIO_flush(statePtr->bio);

		if (err <= 0) {
			dprintf("Flushing failed");

			*errorCodePtr = EIO;
			written = 0;
			return(-1);
		}

		written = 0;
		*errorCodePtr = 0;
		return(0);
	}

	/*
	 * We need to clear the SSL error stack now because we sometimes reach
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
			*errorCodePtr = ECONNABORTED;
			written = -1;
			break;
		default:
			dprintf(" unknown err: %d", err);
			break;
	}
output:
	dprintf("Output(%d) -> %d", toWrite, written);
	return(written);
}

/*
 *-------------------------------------------------------------------
 *







|







376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
			*errorCodePtr = ECONNABORTED;
			written = -1;
			break;
		default:
			dprintf(" unknown err: %d", err);
			break;
	}

	dprintf("Output(%d) -> %d", toWrite, written);
	return(written);
}

/*
 *-------------------------------------------------------------------
 *
773
774
775
776
777
778
779
780




781
782
783
784
785
786
787

			err = SSL_connect(statePtr->ssl);
		}

		if (err > 0) {
			dprintf("That seems to have gone okay");

			BIO_flush(statePtr->bio);




		}

		rc = SSL_get_error(statePtr->ssl, err);

		dprintf("Got error: %i (rc = %i)", err, rc);

		bioShouldRetry = 0;







|
>
>
>
>







782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800

			err = SSL_connect(statePtr->ssl);
		}

		if (err > 0) {
			dprintf("That seems to have gone okay");

			err = BIO_flush(statePtr->bio);

			if (err <= 0) {
				dprintf("Flushing the lower layers failed, this will probably terminate this session");
			}
		}

		rc = SSL_get_error(statePtr->ssl, err);

		dprintf("Got error: %i (rc = %i)", err, rc);

		bioShouldRetry = 0;