Changeset 10756


Ignore:
Timestamp:
02/12/10 20:26:50 (2 years ago)
Author:
submersible_toaster
Message:

make the incremental json parsing less broken when reading from wxsocket

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre-Plugin-Swarm/lib/Padre/Plugin/Swarm/Transport/Global/WxSocket.pm

    r10755 r10756  
    152152    my $marshal = $self->marshal; 
    153153     
    154     my @messages; 
    155154    my $data = ''; 
     155    my $buffer; 
    156156    # Read chunks of data from the socket until there is 
    157157    # no more to read, feeding it into the decoder. 
    158158    # TODO - can we yield to WxIdle in here? .. safely? 
    159     while ( $sock->Read( $data, 1024, length($data)  ) ) { 
    160         my @m = eval { $marshal->incr_parse($data) }; 
    161         if ($@) { 
     159    while ( $sock->Read( $data, 1024, 0  ) ) { 
     160        $buffer .= $data; 
     161        $data=''; 
     162    } 
     163    eval { $marshal->incr_parse($buffer) }; # VOID context pls!! 
     164    TRACE( "Pumped $buffer from socket" ) if DEBUG; 
     165    my @messages; 
     166    push @messages , eval { $marshal->incr_parse() }; 
     167    if ($@) { 
    162168            TRACE( "Unparsable message - $@" ) if DEBUG; 
    163             $marshal->incr_skip; 
    164         } else { 
    165             push @messages ,@m if @m; 
    166         } 
    167         $data=''; 
     169            #$marshal->incr_skip; 
    168170    } 
    169171     
Note: See TracChangeset for help on using the changeset viewer.