Changeset 4692 for trunk


Ignore:
Timestamp:
Nov 10, 2014 10:44:18 AM (6 years ago)
Author:
ldelgass
Message:

Add command sequence counter (this should match the server's command tokens
returned in ok/ack replies), tracing of commands and replies to console. Also,
clear output buffer from SendHelper? and print an error message if we re-
enter SendBytes? causing the output buffer to be clobbered.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/visviewer.tcl

    r4492 r4692  
    4747    protected variable _outbuf       ;    # buffer for outgoing commands
    4848    protected variable _buffering 0
    49 
    50     private variable _logging 0
     49    protected variable _cmdSeq 0     ;    # Command sequence number
     50
     51    private variable _trace 0        ;    # Protocol tracing for console
     52    private variable _logging 0      ;    # Command logging to file
    5153
    5254    protected variable _dispatcher "";  # dispatcher for !events
     
    320322    set _buffer(in) ""
    321323    set _outbuf ""
     324    set _cmdSeq 0
    322325}
    323326
     
    400403    puts -nonewline $_sid $_buffer(out)
    401404    flush $_sid
     405    set _buffer(out) ""
    402406    set _done($this) 1;                 # Success
    403407}
     
    453457    # before sending anything.
    454458    set _done($this) 1
     459    if {$_buffer(out) != ""} {
     460        puts stderr "ERROR: re-entered SendBytes: buffer=([string range $_buffer(out) 0 70]...)"
     461        puts stderr "New cmd $_cmdSeq: [string range $bytes 0 70]..."
     462    }
    455463    set _buffer(out) $bytes
    456     if {1} {
     464    if {0} {
    457465        # Let's try this approach: allow a write to block so we don't
    458466        # re-enter SendBytes
     
    461469        # This can cause us to re-enter SendBytes during the tkwait, which
    462470        # is not safe because the _buffer will be clobbered
     471        blt::busy hold $itk_component(main)
    463472        fileevent $_sid writable [itcl::code $this SendHelper]
    464473        tkwait variable ::Rappture::VisViewer::_done($this)
     474        blt::busy release $itk_component(main)
    465475    }
    466476    set _buffer(out) ""
     
    547557    if { [string compare -length 3 $line "nv>"] == 0 } {
    548558        ReceiveEcho <<line $line
     559        if ($_trace) {
     560            puts stderr "<<[string range $line 0 70]"
     561        }
    549562        append _buffer(in) [string range $line 3 end]
    550563        append _buffer(in) "\n"
     
    809822# ----------------------------------------------------------------------
    810823itcl::body Rappture::VisViewer::SendDebugCommand {} {
     824    incr _cmdSeq
    811825    set cmd [$itk_component(command) get]
    812826    append cmd "\n"
     827    if {$_trace} {
     828        puts stderr "$_cmdSeq>>[string range $cmd 0 70]"
     829    }
    813830    SendBytes $cmd
    814831    $itk_component(command) delete 0 end
     
    11741191#
    11751192itcl::body Rappture::VisViewer::SendCmd {string} {
     1193    incr _cmdSeq
     1194    if {$_trace} {
     1195        puts stderr "$_cmdSeq>>[string range $string 0 70]"
     1196    }
    11761197    if { $_buffering } {
    11771198        append _outbuf $string "\n"
     
    11891210#
    11901211itcl::body Rappture::VisViewer::SendCmdNoWait {string} {
     1212    incr _cmdSeq
     1213    if {$_trace} {
     1214        puts stderr "$_cmdSeq>>[string range $string 0 70]"
     1215    }
    11911216    if { $_buffering } {
    11921217        append _outbuf $string "\n"
Note: See TracChangeset for help on using the changeset viewer.