Tcl Source Code

Check-in [7e674627c1]
Login

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

Overview
Comment: * generic/tclIO.c (BUSY_STATE, CheckChannelErrors, TclCopyChannel): New macro, and the places using it. This change allows for bi-directional fcopy on channels. Thanks to Alexandre Ferrieux <[email protected]> for the patch.
* tests/io.test (io-53.9): Made test cleanup robust against the possibility of slow process shutdown on Windows. Backported from Kevin Kenny's change to the same test on the 8.5 and head branches.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-4-branch
Files: files | file ages | folders
SHA1: 7e674627c1f318cf9cbf9c292b42ec1900e3ac8d
User & Date: andreas_kupries 2008-04-07 19:40:57
Context
2008-04-07
19:53
Added forgotten reference to [Bug 1350564] in last entry. check-in: 6222635d52 user: andreas_kupries tags: core-8-4-branch
19:40
* generic/tclIO.c (BUSY_STATE, CheckChannelErrors, TclCopyChannel): New macro, and the places u... check-in: 7e674627c1 user: andreas_kupries tags: core-8-4-branch
2008-04-04
20:00
* tests/io.test (io-53.9): Added testcase for [Bug 780533], based on Alexandre's test script. A... check-in: c22464c9bd user: andreas_kupries tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.













1
2
3
4
5
6
7












2008-04-04  Andreas Kupries  <[email protected]>

	* tests/io.test (io-53.9): Added testcase for [Bug 780533], based
	  on Alexandre's test script. Also fixed problem with timer in
	  preceding test, was not canceled properly in the ok case.

2008-04-03  Andreas Kupries  <[email protected]>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2008-04-07  Andreas Kupries  <[email protected]>

	* generic/tclIO.c (BUSY_STATE, CheckChannelErrors,
	  TclCopyChannel): New macro, and the places using it. This change
	  allows for bi-directional fcopy on channels. Thanks to Alexandre
	  Ferrieux <[email protected]> for the patch.

	* tests/io.test (io-53.9): Made test cleanup robust against the
	  possibility of slow process shutdown on Windows. Backported from
	  Kevin Kenny's change to the same test on the 8.5 and head
	  branches.

2008-04-04  Andreas Kupries  <[email protected]>

	* tests/io.test (io-53.9): Added testcase for [Bug 780533], based
	  on Alexandre's test script. Also fixed problem with timer in
	  preceding test, was not canceled properly in the ok case.

2008-04-03  Andreas Kupries  <[email protected]>

Changes to generic/tclIO.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* 
 * tclIO.c --
 *
 *	This file provides the generic portions (those that are the same on
 *	all platforms and for all channel types) of Tcl's IO facilities.
 *
 * Copyright (c) 1998-2000 Ajuba Solutions
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclIO.c,v 1.61.2.25 2008/04/03 18:06:52 andreas_kupries Exp $
 */

#include "tclInt.h"
#include "tclPort.h"
#include "tclIO.h"
#include <assert.h>













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* 
 * tclIO.c --
 *
 *	This file provides the generic portions (those that are the same on
 *	all platforms and for all channel types) of Tcl's IO facilities.
 *
 * Copyright (c) 1998-2000 Ajuba Solutions
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclIO.c,v 1.61.2.26 2008/04/07 19:40:58 andreas_kupries Exp $
 */

#include "tclInt.h"
#include "tclPort.h"
#include "tclIO.h"
#include <assert.h>

152
153
154
155
156
157
158




159
160
161
162
163
164
165
				int *dstLenPtr, int *srcLenPtr));
static void		UpdateInterest _ANSI_ARGS_((Channel *chanPtr));
static int		WriteBytes _ANSI_ARGS_((Channel *chanPtr,
				CONST char *src, int srcLen));
static int		WriteChars _ANSI_ARGS_((Channel *chanPtr,
				CONST char *src, int srcLen));






/*
 *---------------------------------------------------------------------------
 *
 * TclInitIOSubsystem --
 *
 *	Initialize all resources used by this subsystem on a per-process







>
>
>
>







152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
				int *dstLenPtr, int *srcLenPtr));
static void		UpdateInterest _ANSI_ARGS_((Channel *chanPtr));
static int		WriteBytes _ANSI_ARGS_((Channel *chanPtr,
				CONST char *src, int srcLen));
static int		WriteChars _ANSI_ARGS_((Channel *chanPtr,
				CONST char *src, int srcLen));

#define BUSY_STATE(st,fl) \
    ((st)->csPtr && \
     ( (((fl)&TCL_READABLE)&&((st)->csPtr->readPtr ==(st)->topChanPtr)) || \
       (((fl)&TCL_WRITABLE)&&((st)->csPtr->writePtr==(st)->topChanPtr))))

/*
 *---------------------------------------------------------------------------
 *
 * TclInitIOSubsystem --
 *
 *	Initialize all resources used by this subsystem on a per-process
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
     * Fail if the channel is in the middle of a background copy.
     *
     * Don't do this tests for raw channels here or else the chaining in the
     * transformation drivers will fail with 'file busy' error instead of
     * retrieving and transforming the data to copy.
     */

    if ((statePtr->csPtr != NULL) && ((flags & CHANNEL_RAW_MODE) == 0)) {
	Tcl_SetErrno(EBUSY);
	return -1;
    }

    if (direction == TCL_READABLE) {
	/*
	 * If we have not encountered a sticky EOF, clear the EOF bit







|







5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
     * Fail if the channel is in the middle of a background copy.
     *
     * Don't do this tests for raw channels here or else the chaining in the
     * transformation drivers will fail with 'file busy' error instead of
     * retrieving and transforming the data to copy.
     */

    if (BUSY_STATE(statePtr,flags) && ((flags & CHANNEL_RAW_MODE) == 0)) {
	Tcl_SetErrno(EBUSY);
	return -1;
    }

    if (direction == TCL_READABLE) {
	/*
	 * If we have not encountered a sticky EOF, clear the EOF bit
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
    int readFlags, writeFlags;
    CopyState *csPtr;
    int nonBlocking = (cmdPtr) ? CHANNEL_NONBLOCKING : 0;

    inStatePtr	= inPtr->state;
    outStatePtr	= outPtr->state;

    if (inStatePtr->csPtr) {
	if (interp) {
	    Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"",
		    Tcl_GetChannelName(inChan), "\" is busy", NULL);
	}
	return TCL_ERROR;
    }
    if (outStatePtr->csPtr) {
	if (interp) {
	    Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"",
		    Tcl_GetChannelName(outChan), "\" is busy", NULL);
	}
	return TCL_ERROR;
    }








|






|







7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
    int readFlags, writeFlags;
    CopyState *csPtr;
    int nonBlocking = (cmdPtr) ? CHANNEL_NONBLOCKING : 0;

    inStatePtr	= inPtr->state;
    outStatePtr	= outPtr->state;

    if (BUSY_STATE(inStatePtr,TCL_READABLE)) {
	if (interp) {
	    Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"",
		    Tcl_GetChannelName(inChan), "\" is busy", NULL);
	}
	return TCL_ERROR;
    }
    if (BUSY_STATE(outStatePtr,TCL_WRITABLE)) {
	if (interp) {
	    Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"",
		    Tcl_GetChannelName(outChan), "\" is busy", NULL);
	}
	return TCL_ERROR;
    }

Changes to tests/io.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright (c) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: io.test,v 1.40.2.14 2008/04/04 20:01:00 andreas_kupries Exp $

if {[catch {package require tcltest 2}]} {
    puts stderr "Skipping tests in [info script].  tcltest 2 required."
    return
}
namespace eval ::tcl::test::io {








|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright (c) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: io.test,v 1.40.2.15 2008/04/07 19:41:00 andreas_kupries Exp $

if {[catch {package require tcltest 2}]} {
    puts stderr "Skipping tests in [info script].  tcltest 2 required."
    return
}
namespace eval ::tcl::test::io {

7004
7005
7006
7007
7008
7009
7010

7011
7012
7013
7014
7015
7016
7017
    }]
    vwait ::forever
    catch {after cancel $token}
    set ::forever
} -cleanup {
    close $pipe
    rename ::done {}

    removeFile out
    removeFile err
    catch {unset ::forever}
} -result OK

test io-54.1 {Recursive channel events} {socket fileevent} {
    # This test checks to see if file events are delivered during recursive







>







7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
    }]
    vwait ::forever
    catch {after cancel $token}
    set ::forever
} -cleanup {
    close $pipe
    rename ::done {}
    after 1000 ;# Give Windows time to kill the process
    removeFile out
    removeFile err
    catch {unset ::forever}
} -result OK

test io-54.1 {Recursive channel events} {socket fileevent} {
    # This test checks to see if file events are delivered during recursive