Ticket UUID: | 1350564 | |||
Title: | Inadequate fcopy operation | |||
Type: | Bug | Version: | obsolete: 8.4.11 | |
Submitter: | setok | Created on: | 2005-11-07 18:05:33 | |
Subsystem: | 25. Channel System | Assigned To: | aku | |
Priority: | 9 Immediate | Severity: | Minor | |
Status: | Closed | Last Modified: | 2014-04-28 20:34:20 | |
Resolution: | Fixed | Closed By: | ferrieux | |
Closed on: | 2014-04-28 20:34:20 | |||
Description: |
If I am doing an [fcopy] from chan1 to chan2 I cannot use a readable fileevent for chan1. This is completely understandable, but why does it not work the other way round? I would like to copy data from chan1 but also react to any responses coming from chan2 as soon as they arrive. However, this is not possible. Neither is setting a writable fileevent for chan1. | |||
User Comments: |
ferrieux added on 2014-04-28 20:34:20:
Committed a clarification to fcopy.n [check-in a6e8d5d50c]. Thanks for feedback. ferrieux added on 2014-04-28 20:10:44: > BTW, can I multiplex a single source into > multiple destinations with fcopy (as tee(1) > would do)? Should I be able to? Not "out of the box", because async fcopy is a simple-minded "byte noria", that essentially spends its life alternating a readable and a writable fileevent (in C), guaranteeing no accumulation in memory. The noria requires to be alone fiddling with fileevents in that direction, otherwise there would be a race on the read side. If instead you want to "fork the flow", simply do a single fcopy towards a synthetic channel (refchan) that duplicates. mi added on 2014-04-28 19:11:13:
Though the fix (improvement) was committed into Tcl C-code, the documentation was never updated. The man-page for fcopy(n) still states: You are not allowed to do other I/O operations with inchan or outchan during a background fcopy. The above sentence should be clarified and an example of bi-directional fcopy be added. BTW, can I multiplex a single source into multiple destinations with fcopy (as tee(1) would do)? Should I be able to? andreas_kupries added on 2008-04-08 02:50:09: Logged In: YES user_id=75003 Originator: NO And Alexandre is now on the developer's list for Tcl, currently only for 'Tracker Admin'. That should allow him to attach patches to other tracker item than his own. andreas_kupries added on 2008-04-08 02:44:56: Logged In: YES user_id=75003 Originator: NO Functionality committed to 8.4, 8.5, and head branches. Test case will follow. andreas_kupries added on 2008-04-07 22:44:10: Logged In: YES user_id=75003 Originator: NO True that. dgp added on 2008-04-05 11:47:15: Logged In: YES user_id=80530 Originator: NO let's just add ferrieux to the Developers list so he can attach patches. If his worthy contributions keep up, a maintainer hat for him may be in the mail. :) andreas_kupries added on 2008-04-05 05:57:05: File Added - 273293: fcopy-dual.tar.gz Logged In: YES user_id=75003 Originator: NO File Added: fcopy-dual.tar.gz andreas_kupries added on 2008-04-05 05:44:52: Logged In: YES user_id=75003 Originator: NO Send them to me and I as maintainer should be able to attach them. ferrieux added on 2008-04-05 05:36:39: Logged In: YES user_id=496139 Originator: NO Fixed. Attaching a patch (including the two other recent fixes to fcopy) refining the blindly symmetrical busy test (non-null csPtr) by a direction-specific one. The refined test is: #define BUSY_STATE(st,fl) \ ((st)->csPtr && \ ( (((fl)&TCL_READABLE)&&((st)->csPtr->readPtr==(st)->topChanPtr)) || \ (((fl)&TCL_WRITABLE)&&((st)->csPtr->writePtr==(st)->topChanPtr)))) Also attaching 4 test scripts: - fev[12].tcl: run in two separate tclsh's, use an async fcopy and a reverse fileevent readable. - inetc.tcl,noria.tcl: run in three tclsh's: one noria and two inetcs, this establishes a bidirectional fcopy: anything typed into one inetc is displayed on the other one and vice versa. Last minute: heck, I cannot attach any files since I'm not the reporter ! What can I do ? setok added on 2005-11-23 18:24:27: Logged In: YES user_id=137542 The manpage clearly states that no IO can be done with either channel. Presumably that would include reading from the outChan. In fact, I have seen this occur where I get something like a "channel is busy" error. I am not sure if your example is good for testing this as in such a small case it will likely have written out all data before the fileevent is triggered. coldstore added on 2005-11-22 14:30:55: Logged In: YES user_id=19214 I'm not sure I follow ... the following code seems to work as I would expect it to, in a recent 8.5 - regardless of whether the [fileevent] occurs before or after the [fcopy]. Is the problem that a readable event won't trigger while the [fcopy] is active (that is, before Done is called?) proc readable {sock} { puts stderr "R: [gets $sock]" } proc done {args} { puts stderr "DONE: $args" } proc accept {sock args} { puts stderr "accept $args" set fd [open fcopy-socket.tcl r] fcopy $fd $sock -command done fileevent $sock readable [list readable $sock] } socket -server accept 9999 vwait forever |
Attachments:
- fcopy-dual.tar.gz [download] added by andreas_kupries on 2008-04-05 05:57:04. [details]