THRIFT-926. cpp: Fix inconsistencies in transport read() behavior
authorDavid Reiss <dreiss@apache.org>
Wed, 6 Oct 2010 17:10:40 +0000 (17:10 +0000)
committerDavid Reiss <dreiss@apache.org>
Wed, 6 Oct 2010 17:10:40 +0000 (17:10 +0000)
commit0a2d81e81614a73590056b4fea7688463df7c80b
treef7640d3608c2a2ddcc3cb6508c060ec05b7277df
parente5c435cccf4fdc5650c6127563b3b61de65e1762
THRIFT-926. cpp: Fix inconsistencies in transport read() behavior

- TBufferedTransport::borrow() could block if not enough data was
  available.  Now it returns NULL immediately in this case, like all
  other transports.

- TBufferedTransport::read() could block some data was available in the
  readahead buffer, but not enough to satisfy the request.  It would
  attempt to call read() on the underlying transport, but this might
  block.  Now it just returns the remaining data in the readahead
  buffer.  The caller is responsible for calling read() again to get the
  rest of the data they want.

- TFrameTransport::read() threw an exception if read() on the underlying
  transport returned 0 when looking for a frame header.  Now
  TFrameTransport::read() returns 0, too.  (It still throws an exception
  if the underlying transport returns 0 after a partial frame or frame
  header has been read.)

- TFDTransport::read() threw an exception on EINTR.  Now it retries up
  to 5 times, similarly to the way TSocket::read() behaves.

- TZlibTransport::read() could block when less data than was requested
  is available.  Now it only calls read() on the underlying transport
  when it would otherwise have nothing to return.

  This does mean that TZlibTransport::read() now often returns less data
  than is actually available at the time.  This required updating
  several of the ZlibTest tests to use readAll() instead of read(),
  since they previously assumed read() would return all available data.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005161 13f79535-47bb-0310-9956-ffa450edef68
lib/cpp/src/transport/TBufferTransports.cpp
lib/cpp/src/transport/TBufferTransports.h
lib/cpp/src/transport/TFDTransport.cpp
lib/cpp/src/transport/TZlibTransport.cpp
lib/cpp/test/TransportTest.cpp
lib/cpp/test/ZlibTest.cpp