thrift/lib/cpp
David Reiss e5c435cccf THRIFT-929. cpp: Add tests to verify blocking read behavior
Add tests that check to see whether or not read() and borrow() block
when called with a length larger than the amount of data currently
available.

At the moment, not all of the transports behave the same way.  I believe
the desired behavior is:

  When M bytes are available, and 0 < M < N:
  - read(N): return M bytes immediately
  - borrow(N): return NULL immediately

  When 0 bytes are available:
  - read(N): In this case, it is acceptable either to immediately return
    0, or to block until some data is available.  If the transport
    blocks, it returns immediately when some date becomes available,
    even if less than N bytes are available.
  - borrow(N): return NULL immediately

- The borrow() tests fail when using TBufferedTransport.
  TBufferedTransport incorrectly blocks until the amount of data
  requested is available.

- test_read_none_available() fails when using TFramedTransport.
  Calling read() on a TFramedTransport when no data is available throws
  an exception instead of returning 0.

- test_read_none_available() fails when using TFDTransport.  This is
  partly just an artifact of the fact that I use SIGALRM as part of this
  test.  Unlike TSocket, TFDTransport doesn't retry after EINTR.

- test_read_part_available() fails when using TZlibTransport around a
  transport that has blocking read() behavior.  TZlibTransport::read()
  loops calling read() on the underlying transport.  It should probably
  break out of the loop and return to the caller as soon as it has
  uncompressed any data, even if it is less than requested and more
  might be available.  Once some data has been uncompressed,
  TZlibTransport cannot risk calling read() again since it might block.

Will commit fixes for these separately.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005160 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:38 +00:00
..
src THRIFT-926. cpp: Fix bugs in TFileTransport::flush() 2010-10-06 17:10:33 +00:00
test THRIFT-929. cpp: Add tests to verify blocking read behavior 2010-10-06 17:10:38 +00:00
Makefile.am THRIFT-922. cpp: Templatize binary and compact protocol 2010-10-06 17:09:56 +00:00
README THRIFT-387. Add appropriate Apache header to all code files 2009-04-08 00:19:37 +00:00
thrift-nb.pc.in THRIFT-387. Add license to pkgconfig files 2009-03-30 22:52:42 +00:00
thrift-z.pc.in THRIFT-387. Add license to pkgconfig files 2009-03-30 22:52:42 +00:00
thrift.pc.in THRIFT-387. Add license to pkgconfig files 2009-03-30 22:52:42 +00:00

Thrift C++ Software Library

License
=======

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

Using Thrift with C++
=====================

The Thrift C++ libraries are built using the GNU tools. Follow the instructions
in the top-level README, or run bootstrap.sh in this folder to generate the
Makefiles.

In case you do not want to open another README file, do this:
  ./bootstrap.sh
  ./configure (--with-boost=/usr/local)
  make
  sudo make install

Thrift is divided into two libraries.

libthrift
  The core Thrift library contains all the core Thrift code. It requires
  boost shared pointers, pthreads, and librt.

libthriftnb
  This library contains the Thrift nonblocking server, which uses libevent.
  To link this library you will also need to link libevent.

Linking Against Thrift
======================

After you build and install Thrift the libraries are installed to
/usr/local/lib by default. Make sure this is in your LDPATH.

On Linux, the best way to do this is to ensure that /usr/local/lib is in
your /etc/ld.so.conf and then run /sbin/ldconfig.

Depending upon whether you are linking dynamically or statically and how
your build environment it set up, you may need to include additional
libraries when linking against thrift, such as librt and/or libpthread. If
you are using libthriftnb you will also need libevent.

Dependencies
============

boost shared pointers
http://www.boost.org/libs/smart_ptr/smart_ptr.htm

libevent (for libthriftnb only)
http://monkey.org/~provos/libevent/