Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0a7fbc4613b4d4b09eaff24b1aa3384295abe279
Ticket: 462317ffffffffffffffffffffffffffffffffff
Notification when there's no data
User & Date: andreas_kupries on 2001-09-27 09:08:27
Changes

  1. icomment:
    
    
    File Added - 11261: 462317.diff.0
    
    Logged In: YES 
    user_id=75003
    
    In direct interaction with Kevin
    (email) it was determined that the
    following interacting factors generated
    the problem reported here. A patch to
    the Tcl I/O core was created and tested
    extensively. The patch survives the
    testsuite and also removes the reported
    deadlock.
    
    The patch here is the second one to fix
    the bug. The first patch was done
    against Expect itself and whipped up to
    provide a more immediate workaround
    while trying to find the trouble spot.
    
    - Tcl had a number of bytes in its
      input buffers and used a timer to
      generate artificial fileevents to
      drain them.
    
    - Expect received these events and read
      data from the channel. It also asked
      for more data than was buffered.
    
    - Epect had set the pty channel to
      non-blocking and therefore expected
      to get short reads if asking for data
      than available.
    
    - The associated pty channel driver did
      not provide a blockmodeproc through
      which the Tcl I/O core tells a driver
      whether a channel is blocking or not.
    
      IOW, while the Tcl I/O core had to
      provide non-blocking semantics the
      underlying OS call was actually
      blocking.
    
    - When Expect asked for more data than
      available the Tcl I/O core started to
      read from OS, assuming that the
      underlying OS call would not block as
      the channel was set non-blocking. The
      call was blocking instead and closed
      the chain of dependencies, creating
      the deadlock.
    
    Solution:
    
    The Tcl I/O is changed to
    
    - assume that the underlying OS calls
      are blocking if a driver does not
      provide a blockmodeproc.
    
    - never try to read from the OS if it
      is not certain that data is available,
      non-blocking behaviour is expected by
      the caller and the underlying OS call
      assumed to be blocking.
    
    The last item means in practice that
    read requests generated while handling
    a timer generated fileevent are
    restricted to the data in the input
    buffers of the channel in question.
    
    Trying to read more will signal
    EWOULDBLOCK and cause the caller to see
    a short read.
    
    
    
  2. login: "andreas_kupries"
  3. mimetype: "text/plain"
  4. priority changed to: "7 High"
  5. resolution changed to: "Fixed"
  6. username: "andreas_kupries"