Changeset 6156 for branches


Ignore:
Timestamp:
Mar 20, 2016 2:47:36 AM (8 years ago)
Author:
ldelgass
Message:

merge r6011 from trunk (append to output buffer in visviewer)

Location:
branches/1.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5

    • Property svn:mergeinfo changed
      /trunkmerged: 6011
  • branches/1.5/gui/scripts/visviewer.tcl

    r6127 r6156  
    7474    private method SendDebugCommand {}
    7575    private method SendHelper {}
    76     private method SendHelper.old {}
    7776    private method ServerDown {}
    7877    private method Shuffle { servers }
     
    332331    set _sid ""
    333332    set _buffer(in) ""
     333    set _buffer(out) ""
    334334    set _outbuf ""
    335335    set _cmdSeq 0
     
    419419
    420420#
    421 # SendHelper.old --
    422 #
    423 #   Helper routine called from a file event to send data when the
    424 #   connection is writable (i.e. not blocked).  Sends data in chunks of 8k
    425 #   (or less).  Sets magic variable _done($this) to indicate that we're
    426 #   either finished (success) or could not send bytes to the server
    427 #   (failure).
    428 #
    429 itcl::body Rappture::VisViewer::SendHelper.old {} {
    430     if { ![CheckConnection] } {
    431         return 0
    432     }
    433     set bytesLeft [string length $_buffer(out)]
    434     if { $bytesLeft > 0} {
    435         set chunk [string range $_buffer(out) 0 8095]
    436         set _buffer(out)  [string range $_buffer(out) 8096 end]
    437         incr bytesLeft -8096
    438         set code [catch {
    439             if { $bytesLeft > 0 } {
    440                 puts -nonewline $_sid $chunk
    441             } else {
    442                 puts $_sid $chunk
    443             }
    444         } err]
    445         if { $code != 0 } {
    446             puts stderr "error sending data to $_sid: $err"
    447             Disconnect
    448             set _done($this) 0;     # Failure
    449         }
    450     } else {
    451         set _done($this) 1;     # Success
    452     }
    453 }
    454 
    455 #
    456421# SendBytes --
    457422#
     
    468433    # before sending anything.
    469434    set _done($this) 1
    470     if {$_trace && $_buffer(out) != ""} {
    471         puts stderr "ERROR: re-entered SendBytes: buffer=([string range $_buffer(out) 0 70]...)"
    472         puts stderr "New cmd $_cmdSeq: [string range $bytes 0 70]..."
    473     }
    474     set _buffer(out) $bytes
     435    if { $_debug && [string bytelength $_buffer(out)] > 0 } {
     436        puts stderr "SendBytes: appending to output buffer"
     437    }
     438    # Append to the buffer, since we may have been called recursively
     439    append _buffer(out) $bytes
    475440    # There's problem when the user is interacting with the GUI at the
    476441    # same time we're trying to write to the server.  Don't want to
     
    479444    # mouse movements aren't received.
    480445    if {$_blockOnWrite} {
    481         # Let's try this approach: allow a write to block so we don't
    482         # re-enter SendBytes
     446        # Allow a write to block.  In this case we won't re-enter SendBytes.
    483447        SendHelper
    484448    } else {
    485         # This can cause us to re-enter SendBytes during the tkwait, which
    486         # is not safe because the _buffer will be clobbered
     449        # NOTE: This can cause us to re-enter SendBytes during the tkwait.
     450        # For this reason, we append to the buffer in the code above.
    487451        if { [info exists itk_component(main)] } {
    488452            blt::busy hold $itk_component(main) -cursor ""
Note: See TracChangeset for help on using the changeset viewer.