Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7b19a96058475a8db17c25aa62db2057afe63cd4
Ticket: 1932639fffffffffffffffffffffffffffffffff
Mixed sync/async [fcopy -command]
User & Date: ferrieux on 2008-04-02 20:49:20
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    In the course of the investigation for [Bug 780533], I
    stumbled upon the following weirdness of the implementation (quoting
    myself since nobody answered that part ;-):
    
    > A side-note about the implementation: if I read correctly, the
    > asynchronous [fcopy] does its first chunk synchronously (in
    > non-blocking mode). This is a bit unusual in event-driven style: setup
    > procedures just set things up, the real work being done only from
    > within [vwait]. While here, a small bit of the copy may be done
    > immediately, even if the program doesn't call vwait before some
    > time...
    > Why is it done this way ? To factor code between sync and async cases ?
    > Do we want it to be this way ? Could it explain nasty context-dependent bugs ?
    
    Now, I'd like to pour in additional evidence that this is just plain wrong.
    
    The idea is that, since [fcopy -command] is both sync and async, an
    error raised in the callback may pop out either synchronously (subject
    to a catch on [fcopy] itslef) or asynchronously (subject to bgerror):
    
    1) Fast transfer (2 bytes):
    
     % proc plop args {puts stderr PLOP:$args;set ::done 1;error yo}
     % set f [open ha r]
     % set n [open nul: w]
     % fconfigure $f -translation binary
     % fconfigure $n -translation binary
     % fcopy $f $n -size 2 -command plop
    PLOP:2
    
     % puts $::errorInfo
    
       while executing
    "fcopy $f $n -size 2 -command plop"
    
    (notice also that the error status is lost, while errorInfo is OK. Yet
    another bug.)
    
    2) Slow transfer (20000 bytes)
    # do the same with -size 20000 and a file longer than that
     - fcopy returns control without PLOP
     - you need to enter a vwait to get the PLOP
    
     (yuck -- the error is lost again; but if it wasn't, it'd be a bgerror)
    
    Questions:
    
     - Is the disabling of errors in the callback intentional, in order to
    hide that catch/bgerror dichotomy ?
    
     - If not, would you accept a patch straightening both issues simultaneously by:
    
          - removing the sync part of [fcopy -async]
          - re-enabling errors in the callback (hell if I know how to do
    this right now)
    
    This way, both examples above would end up in bgerror.
    (Needless to say, I volunteer for the patch)
    
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "ferrieux"
  10. subsystem changed to: "24. Channel Commands"
  11. title changed to: "Mixed sync/async [fcopy -command]"
  12. type changed to: "Bug"