From d622e966d283601cf2fb1cbf87b0fea59a3fe7b4 Mon Sep 17 00:00:00 2001 From: Aditya Agarwal Date: Wed, 11 Oct 2006 02:42:49 +0000 Subject: [PATCH] -- Thrift fixes Summary: -- Made read buffering work (the buffer wasn't actually being used) -- TServer now extends TRunnable (useful for testing) -- Adding TLogging (the DEBUG and ERROR macros that we all know and love) Reviewed By: Slee git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664824 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/Thrift.h | 2 ++ lib/cpp/src/server/TServer.h | 5 ++++- lib/cpp/src/transport/TBufferedTransport.cc | 1 + lib/cpp/src/transport/TBufferedTransport.h | 6 +----- lib/cpp/src/transport/TTransport.h | 3 ++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/cpp/src/Thrift.h b/lib/cpp/src/Thrift.h index c21b0a5e..92143cc9 100644 --- a/lib/cpp/src/Thrift.h +++ b/lib/cpp/src/Thrift.h @@ -10,6 +10,8 @@ #include #include +#include "TLogging.h" + namespace facebook { namespace thrift { class Exception : public std::exception { diff --git a/lib/cpp/src/server/TServer.h b/lib/cpp/src/server/TServer.h index eb23b45a..293aa285 100644 --- a/lib/cpp/src/server/TServer.h +++ b/lib/cpp/src/server/TServer.h @@ -21,10 +21,13 @@ class TServerOptions; * * @author Mark Slee */ -class TServer { +class TServer : public concurrency::Runnable { public: virtual ~TServer() {} virtual void serve() = 0; + + // Allows running the server as a Runnable thread + virtual void run() { serve(); } shared_ptr getProcessor() { return processor_; diff --git a/lib/cpp/src/transport/TBufferedTransport.cc b/lib/cpp/src/transport/TBufferedTransport.cc index cab02dff..9dfd63a3 100644 --- a/lib/cpp/src/transport/TBufferedTransport.cc +++ b/lib/cpp/src/transport/TBufferedTransport.cc @@ -15,6 +15,7 @@ uint32_t TBufferedTransport::read(uint8_t* buf, uint32_t len) { buf += rLen_-rPos_; } // Get more from underlying transport up to buffer size + // TODO: should this be a readAll? rLen_ = transport_->read(rBuf_, rBufSize_); rPos_ = 0; } diff --git a/lib/cpp/src/transport/TBufferedTransport.h b/lib/cpp/src/transport/TBufferedTransport.h index 0783ca41..9992777b 100644 --- a/lib/cpp/src/transport/TBufferedTransport.h +++ b/lib/cpp/src/transport/TBufferedTransport.h @@ -60,12 +60,8 @@ class TBufferedTransport : public TTransport { transport_->close(); } - uint32_t readAll(uint8_t* buf, uint32_t len) { - return transport_->readAll(buf, len); - } - uint32_t read(uint8_t* buf, uint32_t len); - + void write(const uint8_t* buf, uint32_t len); void flush(); diff --git a/lib/cpp/src/transport/TTransport.h b/lib/cpp/src/transport/TTransport.h index 1a20bd5d..c5456d53 100644 --- a/lib/cpp/src/transport/TTransport.h +++ b/lib/cpp/src/transport/TTransport.h @@ -1,6 +1,7 @@ #ifndef _THRIFT_TRANSPORT_TTRANSPORT_H_ #define _THRIFT_TRANSPORT_TTRANSPORT_H_ 1 +#include "Thrift.h" #include #include @@ -72,7 +73,7 @@ class TTransport { } have += get; } - + return have; } -- 2.17.1