thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4187) Dart -> Rust Framed cross tests fail
Date Mon, 15 May 2017 14:42:04 GMT

    [ https://issues.apache.org/jira/browse/THRIFT-4187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16010626#comment-16010626
] 

ASF GitHub Bot commented on THRIFT-4187:
----------------------------------------

Github user markerickson-wf commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/1269#discussion_r116509027
  
    --- Diff: lib/dart/lib/src/transport/t_framed_transport.dart ---
    @@ -51,33 +58,112 @@ class TFramedTransport extends TBufferedTransport {
           if (got > 0) return got;
         }
     
    -    _readFrame();
    +    // IMPORTANT: by the time you've got here,
    +    // an entire frame is available for reading
     
         return super.read(buffer, offset, length);
       }
     
       void _readFrame() {
    -    _transport.readAll(headerBytes, 0, headerByteCount);
    -    int size = headerBytes.buffer.asByteData().getUint32(0);
    +    if (_body == null) {
    +      bool gotFullHeader = _readFrameHeader();
    +      if (!gotFullHeader) {
    +        return;
    +      }
    +    }
    +
    +    _readFrameBody();
    +  }
    +
    +  bool _readFrameHeader() {
    +    var remainingHeaderBytes = headerByteCount - _receivedHeaderBytes;
     
    -    if (size < 0) {
    +    int got = _transport.read(_headerBytes, _receivedHeaderBytes, remainingHeaderBytes);
    +    if (got < 0) {
           throw new TTransportError(
    -          TTransportErrorType.UNKNOWN, "Read a negative frame size: $size");
    +          TTransportErrorType.UNKNOWN, "Socket closed during frame header read");
         }
     
    -    Uint8List buffer = new Uint8List(size);
    -    _transport.readAll(buffer, 0, size);
    -    _setReadBuffer(buffer);
    +    _receivedHeaderBytes += got;
    +
    +    if (_receivedHeaderBytes == headerByteCount) {
    +      int size = _headerBytes.buffer.asByteData().getUint32(0);
    +
    +      _receivedHeaderBytes = 0;
    +
    +      if (size < 0) {
    +        throw new TTransportError(
    +            TTransportErrorType.UNKNOWN, "Read a negative frame size: $size");
    +      }
    +
    +      _bodySize = size;
    +      _body = new Uint8List(_bodySize);
    +      _receivedBodyBytes = 0;
    +
    +      return true;
    +    } else {
    +      _registerForReadableBytes();
    --- End diff --
    
    Does this create a synchronous cycle if the header bytes are not available?  `_registerForReadableBytes`->`_readFrame`->`readFrameHeader`->`_registerForReadableBytes`->...
  It seems like this would cause an unresponsive browser?


> Dart -> Rust Framed cross tests fail
> ------------------------------------
>
>                 Key: THRIFT-4187
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4187
>             Project: Thrift
>          Issue Type: Bug
>          Components: Rust - Library
>            Reporter: Allen George
>            Assignee: Allen George
>            Priority: Minor
>
> For some reason the Dart (client) -> Rust (server) framed-transport cross tests fail.
Initial investigation shows that *somehow* the dart client think the socket was closed, which
means it doesn't read the message from the underlying transport.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message