Simon South created THRIFT-2680:
-----------------------------------

             Summary: c_glib: ThriftFramedTransport fails when peer 
unexpectedly closes connection
                 Key: THRIFT-2680
                 URL: https://issues.apache.org/jira/browse/THRIFT-2680
             Project: Thrift
          Issue Type: Bug
          Components: C glib - Library
    Affects Versions: 0.9.1
         Environment: Fedora 20 64-bit on x86_64
            Reporter: Simon South
            Priority: Minor


Working on the integration test suite for c_glib exposed a problem with 
ThriftFramedTransport: If the peer closes the connection unexpectedly, 
{{thrift_framed_transport_read_frame}} will fail with either a critical GLib 
warning or a segmentation fault.

The attached patches fix this issue. The changes are, in order:

1. Add a suitable test case to {{testframedtransport.c}}.

2. Modify {{thrift_framed_transport_read_frame}} and 
{{thrift_framed_transport_read_frame_slow}} so they check for and respond to 
errors returned from other Thrift methods. Additionally, 
{{thrift_framed_transport_read_frame_slow}} should now always return -1 in case 
of read error, which includes "successfully" reading zero bytes from the peer 
(which generally indicates a prematurely closed connection).

I've also taken the liberty of gently rewriting 
{{thrift_framed_transport_read_frame}} so it

* Correctly uses an unsigned integer variable to hold the frame's size,

* Uses {{thrift_transport_...}} functions to invoke class methods instead of 
the rather brittle practice of dereferencing class members directly, and

* Accurately reports success or failure.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to