Check-in [7e5e4e2114]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added support for detecting writes after we have told the channel that we are in EOF and start returning errors in that case
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-eof-loop-6dd5588df6
Files: files | file ages | folders
SHA1:7e5e4e2114e310cebe61a167ded65fa2d0abeac8
User & Date: rkeene 2017-09-21 14:15:20
Context
2017-09-21
16:07
More soft-EOF mappings Leaf check-in: d63ee30cb2 user: rkeene tags: bug-eof-loop-6dd5588df6
14:15
Added support for detecting writes after we have told the channel that we are in EOF and start returning errors in that case check-in: 7e5e4e2114 user: rkeene tags: bug-eof-loop-6dd5588df6
2017-09-01
00:16
Try harder to ensure the right SSL libraries are used check-in: 6704c33e48 user: rkeene tags: trunk
Changes

Changes to tlsIO.c.

   514    514   
   515    515   	if (statePtr->flags & TLS_TCL_CALLBACK) {
   516    516   		dprintf("Don't process output while callbacks are running")
   517    517   		written = -1;
   518    518   		*errorCodePtr = EAGAIN;
   519    519   		return(-1);
   520    520   	}
          521  +
          522  +	if (statePtr->flags & TLS_TCL_EOF) {
          523  +		dprintf("Asked to write after reaching EOF, we are treating this as fatal.");
          524  +		written = -1;
          525  +		*errorCodePtr = ECONNRESET;
          526  +		return(written);
          527  +	}
   521    528   
   522    529   	dprintf("Calling Tls_WaitForConnect");
   523    530   	tlsConnect = Tls_WaitForConnect(statePtr, errorCodePtr, 1);
   524    531   	if (tlsConnect < 0) {
   525    532   		dprintf("Got an error waiting to connect (tlsConnect = %i, *errorCodePtr = %i)", tlsConnect, *errorCodePtr);
   526    533   
   527    534   		written = -1;
   528    535   		if (*errorCodePtr == ECONNRESET) {
   529         -			dprintf("Got connection reset");
          536  +			dprintf("Got connection reset (setting EOF flag)");
   530    537   			/* Soft EOF */
   531    538   			*errorCodePtr = 0;
   532    539   			written = 0;
          540  +			statePtr->flags |= TLS_TCL_EOF;
   533    541   		}
   534    542   
   535    543   		return(written);
   536    544   	}
   537    545   
   538    546   	if (toWrite == 0) {
   539    547   		dprintf("zero-write");
................................................................................
   582    590   		case SSL_ERROR_WANT_READ:
   583    591   			dprintf(" write R BLOCK");
   584    592   			break;
   585    593   		case SSL_ERROR_WANT_X509_LOOKUP:
   586    594   			dprintf(" write X BLOCK");
   587    595   			break;
   588    596   		case SSL_ERROR_ZERO_RETURN:
   589         -			dprintf(" closed");
          597  +			dprintf(" closed (EOF reached)");
   590    598   			written = 0;
   591    599   			*errorCodePtr = 0;
   592    600   			break;
   593    601   		case SSL_ERROR_SYSCALL:
   594    602   			backingError = ERR_get_error();
   595    603   
   596    604   			if (backingError == 0 && written == 0) {
................................................................................
   613    621   			*errorCodePtr = ECONNABORTED;
   614    622   			written = -1;
   615    623   			break;
   616    624   		default:
   617    625   			dprintf(" unknown err: %d", err);
   618    626   			break;
   619    627   	}
          628  +
          629  +	if (toWrite != 0 && written == 0 && *errorCodePtr == 0) {
          630  +		dprintf("Detected EOF, setting the EOF flag");
          631  +		statePtr->flags |= TLS_TCL_EOF;
          632  +	}
   620    633   
   621    634   	dprintf("Output(%d) -> %d", toWrite, written);
   622    635   	return(written);
   623    636   }
   624    637   
   625    638   /*
   626    639    *-------------------------------------------------------------------

Changes to tlsInt.h.

   122    122   #define TLS_TCL_DEBUG	(1<<3)	/* Show debug tracing */
   123    123   #define TLS_TCL_CALLBACK	(1<<4)	/* In a callback, prevent update
   124    124   					 * looping problem. [Bug 1652380] */
   125    125   #define TLS_TCL_HANDSHAKE_FAILED (1<<5) /* Set on handshake failures and once
   126    126                                            * set, all further I/O will result
   127    127                                            * in ECONNABORTED errors. */
   128    128   #define TLS_TCL_FASTPATH (1<<6)         /* The parent channel is being used directly by the SSL library */
          129  +#define TLS_TCL_EOF (1<<7)         /* We initiated EOF, any further attempts to write will return an error */
   129    130   #define TLS_TCL_DELAY (5)
   130    131   
   131    132   /*
   132    133    * This structure describes the per-instance state
   133    134    * of an ssl channel.
   134    135    *
   135    136    * The SSL processing context is maintained here, in the ClientData