Tcl Source Code

Check-in [dfadac1b71]
Login

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

Overview
Comment:Correct some faulty assumptions in the zlib transformation input driver.

BRANCHED - some other EOF matters need checking before this is trunk ready.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | dgp-eof
Files: files | file ages | folders
SHA1:dfadac1b7136617bcc18b8b6cb11582f9abf3c7d
User & Date: dgp 2014-03-21 19:07:02
Original Comment: Correct some faulty assumptions in the zlib transformation input driver.
Context
2014-03-21
19:07
Correct some faulty assumptions in the zlib transformation input driver.

BRANCHED - some other EO... Closed-Leaf check-in: dfadac1b71 user: dgp tags: dgp-eof

17:11
Added comments raising questions about possible updates to channel drivers on Windows. check-in: 5134ecb54a user: dgp tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclZlib.c.

3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048

3049
3050

3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
		return gotBytes;
	    }

	    *errorCodePtr = Tcl_GetErrno();
	    return -1;
	} else if (readBytes == 0) {
	    /*
	     * Check wether we hit on EOF in 'parent' or not. If not,
	     * differentiate between blocking and non-blocking modes. In
	     * non-blocking mode we ran temporarily out of data. Signal this
	     * to the caller via EWOULDBLOCK and error return (-1). In the
	     * other cases we simply return what we got and let the caller
	     * wait for more. On the other hand, if we got an EOF we have to
	     * convert and flush all waiting partial data.
	     */

	    if (!Tcl_Eof(cd->parent)) {
		/*
		 * The state of the seek system is unchanged!
		 */

		if ((gotBytes == 0) && (cd->flags & ASYNC)) {
		    *errorCodePtr = EWOULDBLOCK;
		    return -1;
		}
		return gotBytes;
	    }

	    /*
	     * (Semi-)Eof in parent.
	     *
	     * Now this is a bit different. The partial data waiting is
	     * converted and returned.
	     */

	    if (ResultGenerate(cd, 0, Z_SYNC_FLUSH, errorCodePtr) != TCL_OK) {
		return -1;
	    }

	    if (Tcl_DStringLength(&cd->decompressed) == 0) {
		/*

		 * The drain delivered nothing. Time to deliver what we've
		 * got.

		 */

		return gotBytes;
	    }

	    /*
	     * Reset eof, force caller to drain result buffer.
	     */

	    ((Channel *) cd->parent)->state->flags &= ~CHANNEL_EOF;
	} else /* readBytes > 0 */ {
	    /*
	     * Transform the read chunk, which was not empty. Anything we get
	     * back is a transformation result to be put into our buffers, and
	     * the next iteration will put it into the result.
	     */








|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






<
|
>
|
|
>
|
<
|
<
<
<
<
<
<
<







3008
3009
3010
3011
3012
3013
3014
3015
3016
3017























3018
3019
3020
3021
3022
3023

3024
3025
3026
3027
3028
3029

3030







3031
3032
3033
3034
3035
3036
3037
		return gotBytes;
	    }

	    *errorCodePtr = Tcl_GetErrno();
	    return -1;
	} else if (readBytes == 0) {
	    /*
	     * The 'parent' is at EOF.   It will not deliver us any more
	     * bytes.  Make one last decompression attempt where we flush
	     * the streams.























	     */

	    if (ResultGenerate(cd, 0, Z_SYNC_FLUSH, errorCodePtr) != TCL_OK) {
		return -1;
	    }


	    /*
	     * Note that in the case where gotBytes == 0 (nothing in
	     * the decompressed buffer to begin with) and the flush
	     * also produce no new output, we are returning 0, which
	     * signals the EOF to our caller.
	     */

	    return gotBytes + ResultCopy(cd, buf, toRead);







	} else /* readBytes > 0 */ {
	    /*
	     * Transform the read chunk, which was not empty. Anything we get
	     * back is a transformation result to be put into our buffers, and
	     * the next iteration will put it into the result.
	     */