Diff

Differences From Artifact [1ceb846355]:

To Artifact [064eb6d39e]:


385
386
387
388
389
390
391







392
393
394
395
396
397
398
	dprintf("BIO_read(%d)", bufSize);

	if (statePtr->flags & TLS_TCL_CALLBACK) {
		/* don't process any bytes while verify callback is running */
		dprintf("Callback is running, reading 0 bytes");
		return(0);
	}








	dprintf("Calling Tls_WaitForConnect");
	tlsConnect = Tls_WaitForConnect(statePtr, errorCodePtr, 0);
	if (tlsConnect < 0) {
		dprintf("Got an error waiting to connect (tlsConnect = %i, *errorCodePtr = %i)", tlsConnect, *errorCodePtr);

		bytesRead = -1;







>
>
>
>
>
>
>







385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
	dprintf("BIO_read(%d)", bufSize);

	if (statePtr->flags & TLS_TCL_CALLBACK) {
		/* don't process any bytes while verify callback is running */
		dprintf("Callback is running, reading 0 bytes");
		return(0);
	}

	if (statePtr->flags & TLS_TCL_EOF) {
		dprintf("Asked to read after reaching EOF, we are treating this as fatal.");
		bytesRead = 0;
		*errorCodePtr = ECONNRESET;
		return(bytesRead);
	}

	dprintf("Calling Tls_WaitForConnect");
	tlsConnect = Tls_WaitForConnect(statePtr, errorCodePtr, 0);
	if (tlsConnect < 0) {
		dprintf("Got an error waiting to connect (tlsConnect = %i, *errorCodePtr = %i)", tlsConnect, *errorCodePtr);

		bytesRead = -1;
474
475
476
477
478
479
480






481
482
483
484
485
486
487
			break;
		default:
			dprintf("Unknown error (err = %i), mapping to EOF", err);
			*errorCodePtr = 0;
			bytesRead = 0;
			break;
	}







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

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







>
>
>
>
>
>







481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
			break;
		default:
			dprintf("Unknown error (err = %i), mapping to EOF", err);
			*errorCodePtr = 0;
			bytesRead = 0;
			break;
	}

	if (bufSize != 0 && bytesRead == 0 && *errorCodePtr == 0) {
		dprintf("Detected EOF, setting the EOF flag");
		statePtr->flags |= TLS_TCL_EOF;
		*errorCodePtr = ECONNRESET;
	}

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

/*
 *-------------------------------------------------------------------
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
		written = -1;
		*errorCodePtr = EAGAIN;
		return(-1);
	}

	if (statePtr->flags & TLS_TCL_EOF) {
		dprintf("Asked to write after reaching EOF, we are treating this as fatal.");
		written = -1;
		*errorCodePtr = ECONNRESET;
		return(written);
	}

	dprintf("Calling Tls_WaitForConnect");
	tlsConnect = Tls_WaitForConnect(statePtr, errorCodePtr, 1);
	if (tlsConnect < 0) {
		dprintf("Got an error waiting to connect (tlsConnect = %i, *errorCodePtr = %i)", tlsConnect, *errorCodePtr);

		written = -1;
		if (*errorCodePtr == ECONNRESET) {
			dprintf("Got connection reset (setting EOF flag)");
			/* Soft EOF */
			*errorCodePtr = 0;
			written = 0;
			statePtr->flags |= TLS_TCL_EOF;
		}

		return(written);
	}








|













|







530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
		written = -1;
		*errorCodePtr = EAGAIN;
		return(-1);
	}

	if (statePtr->flags & TLS_TCL_EOF) {
		dprintf("Asked to write after reaching EOF, we are treating this as fatal.");
		written = 0;
		*errorCodePtr = ECONNRESET;
		return(written);
	}

	dprintf("Calling Tls_WaitForConnect");
	tlsConnect = Tls_WaitForConnect(statePtr, errorCodePtr, 1);
	if (tlsConnect < 0) {
		dprintf("Got an error waiting to connect (tlsConnect = %i, *errorCodePtr = %i)", tlsConnect, *errorCodePtr);

		written = -1;
		if (*errorCodePtr == ECONNRESET) {
			dprintf("Got connection reset (setting EOF flag)");
			/* Soft EOF */
			*errorCodePtr = ECONNRESET;
			written = 0;
			statePtr->flags |= TLS_TCL_EOF;
		}

		return(written);
	}

625
626
627
628
629
630
631

632
633
634
635
636
637
638
			dprintf(" unknown err: %d", err);
			break;
	}

	if (toWrite != 0 && written == 0 && *errorCodePtr == 0) {
		dprintf("Detected EOF, setting the EOF flag");
		statePtr->flags |= TLS_TCL_EOF;

	}

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

/*







>







638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
			dprintf(" unknown err: %d", err);
			break;
	}

	if (toWrite != 0 && written == 0 && *errorCodePtr == 0) {
		dprintf("Detected EOF, setting the EOF flag");
		statePtr->flags |= TLS_TCL_EOF;
		*errorCodePtr = ECONNRESET;
	}

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

/*