diff options
author | ferrieux <ferrieux@users.sourceforge.net> | 2010-12-10 17:00:12 (GMT) |
---|---|---|
committer | ferrieux <ferrieux@users.sourceforge.net> | 2010-12-10 17:00:12 (GMT) |
commit | c62e68e149eae9355fd8af6bd73c7f50b291b9b8 (patch) | |
tree | 142ba2e59b9f44e8c70c68d74aafb1712391f1d1 /generic | |
parent | 64525a0fe7a4adf2979acea69ebb53a3bd8e2071 (diff) | |
download | tcl-c62e68e149eae9355fd8af6bd73c7f50b291b9b8.zip tcl-c62e68e149eae9355fd8af6bd73c7f50b291b9b8.tar.gz tcl-c62e68e149eae9355fd8af6bd73c7f50b291b9b8.tar.bz2 |
Make sure [fcopy -size ... -command ...] always calls the callback asynchronously, even for size zero.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclIO.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 0ed57d0..adc630f 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -10,7 +10,7 @@ * 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.175 2010/03/20 17:49:15 dkf Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.176 2010/12/10 17:00:12 ferrieux Exp $ */ #include "tclInt.h" @@ -8915,6 +8915,33 @@ Tcl_FileEventObjCmd( /* *---------------------------------------------------------------------- * + * ZeroTransferTimerProc -- + * + * Timer handler scheduled by TclCopyChannel so that -command is + * called asynchronously even when -size is 0. + * + * Results: + * None. + * + * Side effects: + * Calls CopyData for -command invocation. + * + *---------------------------------------------------------------------- + */ + +static void +ZeroTransferTimerProc( + ClientData clientData) +{ + /* calling CopyData with mask==0 still implies immediate invocation of the + * -command callback, and completion of the fcopy. + */ + CopyData(clientData, 0); +} + +/* + *---------------------------------------------------------------------- + * * TclCopyChannel -- * * This routine copies data from one channel to another, either @@ -9033,6 +9060,16 @@ TclCopyChannel( outStatePtr->csPtrW = csPtr; /* + * Special handling of -size 0 async transfers, so that the -command is + * still called asynchronously. + */ + + if ((nonBlocking == CHANNEL_NONBLOCKING) && (toRead == 0)) { + Tcl_CreateTimerHandler(0, ZeroTransferTimerProc, csPtr); + return 0; + } + + /* * Start copying data between the channels. */ |