-- 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
diff --git a/lib/cpp/src/Thrift.h b/lib/cpp/src/Thrift.h
index c21b0a5..92143cc 100644
--- a/lib/cpp/src/Thrift.h
+++ b/lib/cpp/src/Thrift.h
@@ -10,6 +10,8 @@
#include <vector>
#include <exception>
+#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 eb23b45..293aa28 100644
--- a/lib/cpp/src/server/TServer.h
+++ b/lib/cpp/src/server/TServer.h
@@ -21,10 +21,13 @@
*
* @author Mark Slee <mcslee@facebook.com>
*/
-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<TProcessor> getProcessor() {
return processor_;
diff --git a/lib/cpp/src/transport/TBufferedTransport.cc b/lib/cpp/src/transport/TBufferedTransport.cc
index cab02df..9dfd63a 100644
--- a/lib/cpp/src/transport/TBufferedTransport.cc
+++ b/lib/cpp/src/transport/TBufferedTransport.cc
@@ -15,6 +15,7 @@
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 0783ca4..9992777 100644
--- a/lib/cpp/src/transport/TBufferedTransport.h
+++ b/lib/cpp/src/transport/TBufferedTransport.h
@@ -60,12 +60,8 @@
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 1a20bd5..c5456d5 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 <transport/TTransportException.h>
#include <string>
@@ -72,7 +73,7 @@
}
have += get;
}
-
+
return have;
}