You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by hc...@apache.org on 2014/11/18 10:02:36 UTC

[08/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TNonblockingServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h
index 532d4ae..7853d54 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.h
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.h
@@ -39,9 +39,9 @@
 #endif
 #include <event.h>
 
-
-
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using apache::thrift::transport::TMemoryBuffer;
 using apache::thrift::transport::TSocket;
@@ -63,27 +63,28 @@ using apache::thrift::concurrency::Guard;
 #define LIBEVENT_VERSION_MAJOR 1
 #define LIBEVENT_VERSION_MINOR 14
 #define LIBEVENT_VERSION_REL 13
-#define LIBEVENT_VERSION_NUMBER ((LIBEVENT_VERSION_MAJOR << 24) | (LIBEVENT_VERSION_MINOR << 16) | (LIBEVENT_VERSION_REL << 8))
+#define LIBEVENT_VERSION_NUMBER                                                                    \
+  ((LIBEVENT_VERSION_MAJOR << 24) | (LIBEVENT_VERSION_MINOR << 16) | (LIBEVENT_VERSION_REL << 8))
 #endif
 
 #if LIBEVENT_VERSION_NUMBER < 0x02000000
- typedef THRIFT_SOCKET evutil_socket_t;
+typedef THRIFT_SOCKET evutil_socket_t;
 #endif
 
 #ifndef SOCKOPT_CAST_T
-#   ifndef _WIN32
-#       define SOCKOPT_CAST_T void
-#   else
-#       define SOCKOPT_CAST_T char
-#   endif // _WIN32
+#ifndef _WIN32
+#define SOCKOPT_CAST_T void
+#else
+#define SOCKOPT_CAST_T char
+#endif // _WIN32
 #endif
 
-template<class T>
+template <class T>
 inline const SOCKOPT_CAST_T* const_cast_sockopt(const T* v) {
   return reinterpret_cast<const SOCKOPT_CAST_T*>(v);
 }
 
-template<class T>
+template <class T>
 inline SOCKOPT_CAST_T* cast_sockopt(T* v) {
   return reinterpret_cast<SOCKOPT_CAST_T*>(v);
 }
@@ -99,22 +100,22 @@ inline SOCKOPT_CAST_T* cast_sockopt(T* v) {
  *
  */
 
-
 /// Overload condition actions.
 enum TOverloadAction {
-  T_OVERLOAD_NO_ACTION,        ///< Don't handle overload */
-  T_OVERLOAD_CLOSE_ON_ACCEPT,  ///< Drop new connections immediately */
-  T_OVERLOAD_DRAIN_TASK_QUEUE  ///< Drop some tasks from head of task queue */
+  T_OVERLOAD_NO_ACTION,       ///< Don't handle overload */
+  T_OVERLOAD_CLOSE_ON_ACCEPT, ///< Drop new connections immediately */
+  T_OVERLOAD_DRAIN_TASK_QUEUE ///< Drop some tasks from head of task queue */
 };
 
 class TNonblockingIOThread;
 
 class TNonblockingServer : public TServer {
- private:
+private:
   class TConnection;
 
   friend class TNonblockingIOThread;
- private:
+
+private:
   /// Listen backlog
   static const int LISTEN_BACKLOG = 1024;
 
@@ -299,33 +300,31 @@ class TNonblockingServer : public TServer {
     nTotalConnectionsDropped_ = 0;
   }
 
- public:
-  template<typename ProcessorFactory>
-  TNonblockingServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      int port,
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory) {
+public:
+  template <typename ProcessorFactory>
+  TNonblockingServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                     int port,
+                     THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory) {
     init(port);
   }
 
-  template<typename Processor>
+  template <typename Processor>
   TNonblockingServer(const boost::shared_ptr<Processor>& processor,
                      int port,
-                     THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor) {
+                     THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor) {
     init(port);
   }
 
-  template<typename ProcessorFactory>
-  TNonblockingServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      int port,
-      const boost::shared_ptr<ThreadManager>& threadManager =
-        boost::shared_ptr<ThreadManager>(),
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory) {
+  template <typename ProcessorFactory>
+  TNonblockingServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                     const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                     int port,
+                     const boost::shared_ptr<ThreadManager>& threadManager
+                     = boost::shared_ptr<ThreadManager>(),
+                     THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory) {
 
     init(port);
 
@@ -334,15 +333,14 @@ class TNonblockingServer : public TServer {
     setThreadManager(threadManager);
   }
 
-  template<typename Processor>
-  TNonblockingServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      int port,
-      const boost::shared_ptr<ThreadManager>& threadManager =
-        boost::shared_ptr<ThreadManager>(),
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor) {
+  template <typename Processor>
+  TNonblockingServer(const boost::shared_ptr<Processor>& processor,
+                     const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                     int port,
+                     const boost::shared_ptr<ThreadManager>& threadManager
+                     = boost::shared_ptr<ThreadManager>(),
+                     THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor) {
 
     init(port);
 
@@ -351,18 +349,17 @@ class TNonblockingServer : public TServer {
     setThreadManager(threadManager);
   }
 
-  template<typename ProcessorFactory>
-  TNonblockingServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      int port,
-      const boost::shared_ptr<ThreadManager>& threadManager =
-        boost::shared_ptr<ThreadManager>(),
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory) {
+  template <typename ProcessorFactory>
+  TNonblockingServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                     const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                     const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                     const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                     const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                     int port,
+                     const boost::shared_ptr<ThreadManager>& threadManager
+                     = boost::shared_ptr<ThreadManager>(),
+                     THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory) {
 
     init(port);
 
@@ -373,18 +370,17 @@ class TNonblockingServer : public TServer {
     setThreadManager(threadManager);
   }
 
-  template<typename Processor>
-  TNonblockingServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      int port,
-      const boost::shared_ptr<ThreadManager>& threadManager =
-        boost::shared_ptr<ThreadManager>(),
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor) {
+  template <typename Processor>
+  TNonblockingServer(const boost::shared_ptr<Processor>& processor,
+                     const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                     const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                     const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                     const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                     int port,
+                     const boost::shared_ptr<ThreadManager>& threadManager
+                     = boost::shared_ptr<ThreadManager>(),
+                     THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor) {
 
     init(port);
 
@@ -399,9 +395,7 @@ class TNonblockingServer : public TServer {
 
   void setThreadManager(boost::shared_ptr<ThreadManager> threadManager);
 
-  boost::shared_ptr<ThreadManager> getThreadManager() {
-    return threadManager_;
-  }
+  boost::shared_ptr<ThreadManager> getThreadManager() { return threadManager_; }
 
   /**
    * Sets the number of IO threads used by this server. Can only be used before
@@ -409,46 +403,32 @@ class TNonblockingServer : public TServer {
    * PosixThreadFactory for the IO worker threads, because they must joinable
    * for clean shutdown.
    */
-  void setNumIOThreads(size_t numThreads) {
-    numIOThreads_ = numThreads;
-  }
+  void setNumIOThreads(size_t numThreads) { numIOThreads_ = numThreads; }
 
   /** Return whether the IO threads will get high scheduling priority */
-  bool useHighPriorityIOThreads() const {
-    return useHighPriorityIOThreads_;
-  }
+  bool useHighPriorityIOThreads() const { return useHighPriorityIOThreads_; }
 
   /** Set whether the IO threads will get high scheduling priority. */
-  void setUseHighPriorityIOThreads(bool val) {
-    useHighPriorityIOThreads_ = val;
-  }
+  void setUseHighPriorityIOThreads(bool val) { useHighPriorityIOThreads_ = val; }
 
   /** Return the number of IO threads used by this server. */
-  size_t getNumIOThreads() const {
-    return numIOThreads_;
-  }
+  size_t getNumIOThreads() const { return numIOThreads_; }
 
   /**
    * Get the maximum number of unused TConnection we will hold in reserve.
    *
    * @return the current limit on TConnection pool size.
    */
-  size_t getConnectionStackLimit() const {
-    return connectionStackLimit_;
-  }
+  size_t getConnectionStackLimit() const { return connectionStackLimit_; }
 
   /**
    * Set the maximum number of unused TConnection we will hold in reserve.
    *
    * @param sz the new limit for TConnection pool size.
    */
-  void setConnectionStackLimit(size_t sz) {
-    connectionStackLimit_ = sz;
-  }
+  void setConnectionStackLimit(size_t sz) { connectionStackLimit_ = sz; }
 
-  bool isThreadPoolProcessing() const {
-    return threadPoolProcessing_;
-  }
+  bool isThreadPoolProcessing() const { return threadPoolProcessing_; }
 
   void addTask(boost::shared_ptr<Runnable> task) {
     threadManager_->add(task, 0LL, taskExpireTime_);
@@ -459,27 +439,21 @@ class TNonblockingServer : public TServer {
    *
    * @return count of connected sockets.
    */
-  size_t getNumConnections() const {
-    return numTConnections_;
-  }
+  size_t getNumConnections() const { return numTConnections_; }
 
   /**
    * Return the count of sockets currently connected to.
    *
    * @return count of connected sockets.
    */
-  size_t getNumActiveConnections() const {
-    return getNumConnections() - getNumIdleConnections();
-  }
+  size_t getNumActiveConnections() const { return getNumConnections() - getNumIdleConnections(); }
 
   /**
    * Return the count of connection objects allocated but not in use.
    *
    * @return count of idle connection objects.
    */
-  size_t getNumIdleConnections() const {
-    return connectionStack_.size();
-  }
+  size_t getNumIdleConnections() const { return connectionStack_.size(); }
 
   /**
    * Return count of number of connections which are currently processing.
@@ -489,9 +463,7 @@ class TNonblockingServer : public TServer {
    *
    * @return # of connections currently processing.
    */
-  size_t getNumActiveProcessors() const {
-    return numActiveProcessors_;
-  }
+  size_t getNumActiveProcessors() const { return numActiveProcessors_; }
 
   /// Increment the count of connections currently processing.
   void incrementActiveProcessors() {
@@ -512,27 +484,21 @@ class TNonblockingServer : public TServer {
    *
    * @return current setting.
    */
-  size_t getMaxConnections() const {
-    return maxConnections_;
-  }
+  size_t getMaxConnections() const { return maxConnections_; }
 
   /**
    * Set the maximum # of connections allowed before overload.
    *
    * @param maxConnections new setting for maximum # of connections.
    */
-  void setMaxConnections(size_t maxConnections) {
-    maxConnections_ = maxConnections;
-  }
+  void setMaxConnections(size_t maxConnections) { maxConnections_ = maxConnections; }
 
   /**
    * Get the maximum # of connections waiting in handler/task before overload.
    *
    * @return current setting.
    */
-  size_t getMaxActiveProcessors() const {
-    return maxActiveProcessors_;
-  }
+  size_t getMaxActiveProcessors() const { return maxActiveProcessors_; }
 
   /**
    * Set the maximum # of connections waiting in handler/task before overload.
@@ -551,27 +517,21 @@ class TNonblockingServer : public TServer {
    *
    * @return Maxium frame size, in bytes.
    */
-  size_t getMaxFrameSize() const {
-    return maxFrameSize_;
-  }
+  size_t getMaxFrameSize() const { return maxFrameSize_; }
 
   /**
    * Set the maximum allowed frame size.
    *
    * @param maxFrameSize The new maximum frame size.
    */
-  void setMaxFrameSize(size_t maxFrameSize) {
-    maxFrameSize_ = maxFrameSize;
-  }
+  void setMaxFrameSize(size_t maxFrameSize) { maxFrameSize_ = maxFrameSize; }
 
   /**
    * Get fraction of maximum limits before an overload condition is cleared.
    *
    * @return hysteresis fraction
    */
-  double getOverloadHysteresis() const {
-    return overloadHysteresis_;
-  }
+  double getOverloadHysteresis() const { return overloadHysteresis_; }
 
   /**
    * Set fraction of maximum limits before an overload condition is cleared.
@@ -590,36 +550,28 @@ class TNonblockingServer : public TServer {
    *
    * @return a TOverloadAction enum value for the currently set action.
    */
-  TOverloadAction getOverloadAction() const {
-    return overloadAction_;
-  }
+  TOverloadAction getOverloadAction() const { return overloadAction_; }
 
   /**
    * Set the action the server is to take on overload.
    *
    * @param overloadAction a TOverloadAction enum value for the action.
    */
-  void setOverloadAction(TOverloadAction overloadAction) {
-    overloadAction_ = overloadAction;
-  }
+  void setOverloadAction(TOverloadAction overloadAction) { overloadAction_ = overloadAction; }
 
   /**
    * Get the time in milliseconds after which a task expires (0 == infinite).
    *
    * @return a 64-bit time in milliseconds.
    */
-  int64_t getTaskExpireTime() const {
-    return taskExpireTime_;
-  }
+  int64_t getTaskExpireTime() const { return taskExpireTime_; }
 
   /**
    * Set the time in milliseconds after which a task expires (0 == infinite).
    *
    * @param taskExpireTime a 64-bit time in milliseconds.
    */
-  void setTaskExpireTime(int64_t taskExpireTime) {
-    taskExpireTime_ = taskExpireTime;
-  }
+  void setTaskExpireTime(int64_t taskExpireTime) { taskExpireTime_ = taskExpireTime; }
 
   /**
    * Determine if the server is currently overloaded.
@@ -643,27 +595,21 @@ class TNonblockingServer : public TServer {
    *
    * @return # bytes we initialize a TConnection object's write buffer to.
    */
-  size_t getWriteBufferDefaultSize() const {
-    return writeBufferDefaultSize_;
-  }
+  size_t getWriteBufferDefaultSize() const { return writeBufferDefaultSize_; }
 
   /**
    * Set the starting size of a TConnection object's write buffer.
    *
    * @param size # bytes we initialize a TConnection object's write buffer to.
    */
-  void setWriteBufferDefaultSize(size_t size) {
-    writeBufferDefaultSize_ = size;
-  }
+  void setWriteBufferDefaultSize(size_t size) { writeBufferDefaultSize_ = size; }
 
   /**
    * Get the maximum size of read buffer allocated to idle TConnection objects.
    *
    * @return # bytes beyond which we will dealloc idle buffer.
    */
-  size_t getIdleReadBufferLimit() const {
-    return idleReadBufferLimit_;
-  }
+  size_t getIdleReadBufferLimit() const { return idleReadBufferLimit_; }
 
   /**
    * [NOTE: This is for backwards compatibility, use getIdleReadBufferLimit().]
@@ -671,9 +617,7 @@ class TNonblockingServer : public TServer {
    *
    * @return # bytes beyond which we will dealloc idle buffer.
    */
-  size_t getIdleBufferMemLimit() const {
-    return idleReadBufferLimit_;
-  }
+  size_t getIdleBufferMemLimit() const { return idleReadBufferLimit_; }
 
   /**
    * Set the maximum size read buffer allocated to idle TConnection objects.
@@ -684,9 +628,7 @@ class TNonblockingServer : public TServer {
    *
    * @param limit of bytes beyond which we will shrink buffers when checked.
    */
-  void setIdleReadBufferLimit(size_t limit) {
-    idleReadBufferLimit_ = limit;
-  }
+  void setIdleReadBufferLimit(size_t limit) { idleReadBufferLimit_ = limit; }
 
   /**
    * [NOTE: This is for backwards compatibility, use setIdleReadBufferLimit().]
@@ -698,20 +640,14 @@ class TNonblockingServer : public TServer {
    *
    * @param limit of bytes beyond which we will shrink buffers when checked.
    */
-  void setIdleBufferMemLimit(size_t limit) {
-    idleReadBufferLimit_ = limit;
-  }
-
-
+  void setIdleBufferMemLimit(size_t limit) { idleReadBufferLimit_ = limit; }
 
   /**
    * Get the maximum size of write buffer allocated to idle TConnection objects.
    *
    * @return # bytes beyond which we will reallocate buffers when checked.
    */
-  size_t getIdleWriteBufferLimit() const {
-    return idleWriteBufferLimit_;
-  }
+  size_t getIdleWriteBufferLimit() const { return idleWriteBufferLimit_; }
 
   /**
    * Set the maximum size write buffer allocated to idle TConnection objects.
@@ -722,18 +658,14 @@ class TNonblockingServer : public TServer {
    *
    * @param limit of bytes beyond which we will shrink buffers when idle.
    */
-  void setIdleWriteBufferLimit(size_t limit) {
-    idleWriteBufferLimit_ = limit;
-  }
+  void setIdleWriteBufferLimit(size_t limit) { idleWriteBufferLimit_ = limit; }
 
   /**
    * Get # of calls made between buffer size checks.  0 means disabled.
    *
    * @return # of calls between buffer size checks.
    */
-  int32_t getResizeBufferEveryN() const {
-    return resizeBufferEveryN_;
-  }
+  int32_t getResizeBufferEveryN() const { return resizeBufferEveryN_; }
 
   /**
    * Check buffer sizes every "count" calls.  This allows buffer limits
@@ -742,9 +674,7 @@ class TNonblockingServer : public TServer {
    *
    * @param count the number of calls between checks, or 0 to disable
    */
-  void setResizeBufferEveryN(int32_t count) {
-    resizeBufferEveryN_ = count;
-  }
+  void setResizeBufferEveryN(int32_t count) { resizeBufferEveryN_ = count; }
 
   /**
    * Main workhorse function, starts up the server listening on a port and
@@ -784,7 +714,7 @@ class TNonblockingServer : public TServer {
    */
   event_base* getUserEventBase() const { return userEventBase_; }
 
- private:
+private:
   /**
    * Callback function that the threadmanager calls when a task reaches
    * its expiration time.  It is needed to clean up the expired connection.
@@ -803,8 +733,7 @@ class TNonblockingServer : public TServer {
    * @param addrLen the length of addr
    * @return pointer to initialized TConnection object.
    */
-  TConnection* createConnection(THRIFT_SOCKET socket, const sockaddr* addr,
-                                            socklen_t addrLen);
+  TConnection* createConnection(THRIFT_SOCKET socket, const sockaddr* addr, socklen_t addrLen);
 
   /**
    * Returns a connection to pool or deletion.  If the connection pool
@@ -817,7 +746,7 @@ class TNonblockingServer : public TServer {
 };
 
 class TNonblockingIOThread : public Runnable {
- public:
+public:
   // Creates an IO thread and sets up the event base.  The listenSocket should
   // be a valid FD on which listen() has already been called.  If the
   // listenSocket is < 0, accepting will not be done.
@@ -868,7 +797,7 @@ class TNonblockingIOThread : public Runnable {
   /// Registers the events for the notification & listen sockets
   void registerEvents();
 
- private:
+private:
   /**
    * C-callable event handler for signaling task completion.  Provides a
    * callback that libevent can understand that will read a connection
@@ -903,7 +832,7 @@ class TNonblockingIOThread : public Runnable {
   /// Sets (or clears) high priority scheduling status for the current thread.
   void setCurrentThreadHighPriority(bool value);
 
- private:
+private:
   /// associated server
   TNonblockingServer* server_;
 
@@ -932,13 +861,14 @@ class TNonblockingIOThread : public Runnable {
   /// Used with eventBase_ for task completion notification
   struct event notificationEvent_;
 
- /// File descriptors for pipe used for task completion notification.
+  /// File descriptors for pipe used for task completion notification.
   evutil_socket_t notificationPipeFDs_[2];
 
   /// Actual IO Thread
   boost::shared_ptr<Thread> thread_;
 };
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TNONBLOCKINGSERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TServer.cpp b/lib/cpp/src/thrift/server/TServer.cpp
old mode 100755
new mode 100644
index 5e82ce6..df731c2
--- a/lib/cpp/src/thrift/server/TServer.cpp
+++ b/lib/cpp/src/thrift/server/TServer.cpp
@@ -30,20 +30,23 @@
 #include <unistd.h>
 #endif
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 #ifdef HAVE_SYS_RESOURCE_H
-int increase_max_fds(int max_fds=(1<<24))  {
+int increase_max_fds(int max_fds = (1 << 24)) {
   struct rlimit fdmaxrl;
 
-  for(fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds;
-      max_fds && (setrlimit(RLIMIT_NOFILE, &fdmaxrl) < 0);
-      fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds) {
+  for (fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds;
+       max_fds && (setrlimit(RLIMIT_NOFILE, &fdmaxrl) < 0);
+       fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds) {
     max_fds /= 2;
   }
 
   return static_cast<int>(fdmaxrl.rlim_cur);
 }
 #endif
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TServer.h b/lib/cpp/src/thrift/server/TServer.h
index 7f718da..c0b222f 100644
--- a/lib/cpp/src/thrift/server/TServer.h
+++ b/lib/cpp/src/thrift/server/TServer.h
@@ -27,7 +27,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using apache::thrift::TProcessor;
 using apache::thrift::protocol::TBinaryProtocolFactory;
@@ -45,8 +47,7 @@ using apache::thrift::transport::TTransportFactory;
  * instance's state).
  */
 class TServerEventHandler {
- public:
-
+public:
   virtual ~TServerEventHandler() {}
 
   /**
@@ -69,8 +70,8 @@ class TServerEventHandler {
    * context.
    */
   virtual void deleteContext(void* serverContext,
-                             boost::shared_ptr<TProtocol>input,
-                             boost::shared_ptr<TProtocol>output) {
+                             boost::shared_ptr<TProtocol> input,
+                             boost::shared_ptr<TProtocol> output) {
     (void)serverContext;
     (void)input;
     (void)output;
@@ -79,19 +80,16 @@ class TServerEventHandler {
   /**
    * Called when a client is about to call the processor.
    */
-  virtual void processContext(void* serverContext,
-                              boost::shared_ptr<TTransport> transport) {
+  virtual void processContext(void* serverContext, boost::shared_ptr<TTransport> transport) {
     (void)serverContext;
     (void)transport;
-}
-
- protected:
+  }
 
+protected:
   /**
    * Prevent direct instantiation.
    */
   TServerEventHandler() {}
-
 };
 
 /**
@@ -99,8 +97,7 @@ class TServerEventHandler {
  *
  */
 class TServer : public concurrency::Runnable {
- public:
-
+public:
   virtual ~TServer() {}
 
   virtual void serve() = 0;
@@ -108,146 +105,122 @@ class TServer : public concurrency::Runnable {
   virtual void stop() {}
 
   // Allows running the server as a Runnable thread
-  virtual void run() {
-    serve();
-  }
+  virtual void run() { serve(); }
 
-  boost::shared_ptr<TProcessorFactory> getProcessorFactory() {
-    return processorFactory_;
-  }
+  boost::shared_ptr<TProcessorFactory> getProcessorFactory() { return processorFactory_; }
 
-  boost::shared_ptr<TServerTransport> getServerTransport() {
-    return serverTransport_;
-  }
+  boost::shared_ptr<TServerTransport> getServerTransport() { return serverTransport_; }
 
-  boost::shared_ptr<TTransportFactory> getInputTransportFactory() {
-    return inputTransportFactory_;
-  }
+  boost::shared_ptr<TTransportFactory> getInputTransportFactory() { return inputTransportFactory_; }
 
   boost::shared_ptr<TTransportFactory> getOutputTransportFactory() {
     return outputTransportFactory_;
   }
 
-  boost::shared_ptr<TProtocolFactory> getInputProtocolFactory() {
-    return inputProtocolFactory_;
-  }
+  boost::shared_ptr<TProtocolFactory> getInputProtocolFactory() { return inputProtocolFactory_; }
 
-  boost::shared_ptr<TProtocolFactory> getOutputProtocolFactory() {
-    return outputProtocolFactory_;
-  }
+  boost::shared_ptr<TProtocolFactory> getOutputProtocolFactory() { return outputProtocolFactory_; }
 
-  boost::shared_ptr<TServerEventHandler> getEventHandler() {
-    return eventHandler_;
-  }
+  boost::shared_ptr<TServerEventHandler> getEventHandler() { return eventHandler_; }
 
 protected:
-  template<typename ProcessorFactory>
+  template <typename ProcessorFactory>
   TServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
-          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)):
-    processorFactory_(processorFactory) {
-    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(
-          new TTransportFactory()));
-    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(
-          new TTransportFactory()));
-    setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(
-          new TBinaryProtocolFactory()));
-    setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(
-          new TBinaryProtocolFactory()));
+          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : processorFactory_(processorFactory) {
+    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+    setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
   }
 
-  template<typename Processor>
-  TServer(const boost::shared_ptr<Processor>& processor,
-          THRIFT_OVERLOAD_IF(Processor, TProcessor)):
-    processorFactory_(new TSingletonProcessorFactory(processor)) {
+  template <typename Processor>
+  TServer(const boost::shared_ptr<Processor>& processor, THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : processorFactory_(new TSingletonProcessorFactory(processor)) {
     setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
     setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
     setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
     setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
   }
 
-  template<typename ProcessorFactory>
+  template <typename ProcessorFactory>
   TServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
           const boost::shared_ptr<TServerTransport>& serverTransport,
-          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)):
-    processorFactory_(processorFactory),
-    serverTransport_(serverTransport) {
-    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(
-          new TTransportFactory()));
-    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(
-          new TTransportFactory()));
-    setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(
-          new TBinaryProtocolFactory()));
-    setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(
-          new TBinaryProtocolFactory()));
+          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : processorFactory_(processorFactory), serverTransport_(serverTransport) {
+    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+    setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
   }
 
-  template<typename Processor>
+  template <typename Processor>
   TServer(const boost::shared_ptr<Processor>& processor,
           const boost::shared_ptr<TServerTransport>& serverTransport,
-          THRIFT_OVERLOAD_IF(Processor, TProcessor)):
-    processorFactory_(new TSingletonProcessorFactory(processor)),
-    serverTransport_(serverTransport) {
+          THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : processorFactory_(new TSingletonProcessorFactory(processor)),
+      serverTransport_(serverTransport) {
     setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
     setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
     setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
     setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
   }
 
-  template<typename ProcessorFactory>
+  template <typename ProcessorFactory>
   TServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
           const boost::shared_ptr<TServerTransport>& serverTransport,
           const boost::shared_ptr<TTransportFactory>& transportFactory,
           const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)):
-    processorFactory_(processorFactory),
-    serverTransport_(serverTransport),
-    inputTransportFactory_(transportFactory),
-    outputTransportFactory_(transportFactory),
-    inputProtocolFactory_(protocolFactory),
-    outputProtocolFactory_(protocolFactory) {}
-
-  template<typename Processor>
+          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : processorFactory_(processorFactory),
+      serverTransport_(serverTransport),
+      inputTransportFactory_(transportFactory),
+      outputTransportFactory_(transportFactory),
+      inputProtocolFactory_(protocolFactory),
+      outputProtocolFactory_(protocolFactory) {}
+
+  template <typename Processor>
   TServer(const boost::shared_ptr<Processor>& processor,
           const boost::shared_ptr<TServerTransport>& serverTransport,
           const boost::shared_ptr<TTransportFactory>& transportFactory,
           const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-          THRIFT_OVERLOAD_IF(Processor, TProcessor)):
-    processorFactory_(new TSingletonProcessorFactory(processor)),
-    serverTransport_(serverTransport),
-    inputTransportFactory_(transportFactory),
-    outputTransportFactory_(transportFactory),
-    inputProtocolFactory_(protocolFactory),
-    outputProtocolFactory_(protocolFactory) {}
-
-  template<typename ProcessorFactory>
+          THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : processorFactory_(new TSingletonProcessorFactory(processor)),
+      serverTransport_(serverTransport),
+      inputTransportFactory_(transportFactory),
+      outputTransportFactory_(transportFactory),
+      inputProtocolFactory_(protocolFactory),
+      outputProtocolFactory_(protocolFactory) {}
+
+  template <typename ProcessorFactory>
   TServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
           const boost::shared_ptr<TServerTransport>& serverTransport,
           const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
           const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
           const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
           const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)):
-    processorFactory_(processorFactory),
-    serverTransport_(serverTransport),
-    inputTransportFactory_(inputTransportFactory),
-    outputTransportFactory_(outputTransportFactory),
-    inputProtocolFactory_(inputProtocolFactory),
-    outputProtocolFactory_(outputProtocolFactory) {}
-
-  template<typename Processor>
+          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : processorFactory_(processorFactory),
+      serverTransport_(serverTransport),
+      inputTransportFactory_(inputTransportFactory),
+      outputTransportFactory_(outputTransportFactory),
+      inputProtocolFactory_(inputProtocolFactory),
+      outputProtocolFactory_(outputProtocolFactory) {}
+
+  template <typename Processor>
   TServer(const boost::shared_ptr<Processor>& processor,
           const boost::shared_ptr<TServerTransport>& serverTransport,
           const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
           const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
           const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
           const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-          THRIFT_OVERLOAD_IF(Processor, TProcessor)):
-    processorFactory_(new TSingletonProcessorFactory(processor)),
-    serverTransport_(serverTransport),
-    inputTransportFactory_(inputTransportFactory),
-    outputTransportFactory_(outputTransportFactory),
-    inputProtocolFactory_(inputProtocolFactory),
-    outputProtocolFactory_(outputProtocolFactory) {}
+          THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : processorFactory_(new TSingletonProcessorFactory(processor)),
+      serverTransport_(serverTransport),
+      inputTransportFactory_(inputTransportFactory),
+      outputTransportFactory_(outputTransportFactory),
+      inputProtocolFactory_(inputProtocolFactory),
+      outputProtocolFactory_(outputProtocolFactory) {}
 
   /**
    * Get a TProcessor to handle calls on a particular connection.
@@ -256,10 +229,9 @@ protected:
    * call).  This allows the TProcessorFactory to return a different processor
    * for each connection if it desires.
    */
-  boost::shared_ptr<TProcessor> getProcessor(
-      boost::shared_ptr<TProtocol> inputProtocol,
-      boost::shared_ptr<TProtocol> outputProtocol,
-      boost::shared_ptr<TTransport> transport) {
+  boost::shared_ptr<TProcessor> getProcessor(boost::shared_ptr<TProtocol> inputProtocol,
+                                             boost::shared_ptr<TProtocol> outputProtocol,
+                                             boost::shared_ptr<TTransport> transport) {
     TConnectionInfo connInfo;
     connInfo.input = inputProtocol;
     connInfo.output = outputProtocol;
@@ -299,7 +271,6 @@ public:
   void setServerEventHandler(boost::shared_ptr<TServerEventHandler> eventHandler) {
     eventHandler_ = eventHandler;
   }
-
 };
 
 /**
@@ -308,9 +279,10 @@ public:
  * By default, tries to increase it to as much as 2^24.
  */
 #ifdef HAVE_SYS_RESOURCE_H
- int increase_max_fds(int max_fds=(1<<24));
+int increase_max_fds(int max_fds = (1 << 24));
 #endif
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TSERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TSimpleServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TSimpleServer.cpp b/lib/cpp/src/thrift/server/TSimpleServer.cpp
index 5fc4c97..fa6bff5 100644
--- a/lib/cpp/src/thrift/server/TSimpleServer.cpp
+++ b/lib/cpp/src/thrift/server/TSimpleServer.cpp
@@ -22,7 +22,9 @@
 #include <string>
 #include <iostream>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using namespace std;
 using namespace apache::thrift;
@@ -59,33 +61,50 @@ void TSimpleServer::serve() {
       inputProtocol = inputProtocolFactory_->getProtocol(inputTransport);
       outputProtocol = outputProtocolFactory_->getProtocol(outputTransport);
     } catch (TTransportException& ttx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
-          string errStr = string("TServerTransport died on accept: ") + ttx.what();
-          GlobalOutput(errStr.c_str());
+        string errStr = string("TServerTransport died on accept: ") + ttx.what();
+        GlobalOutput(errStr.c_str());
       }
       continue;
     } catch (TException& tx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = string("Some kind of accept exception: ") + tx.what();
       GlobalOutput(errStr.c_str());
       continue;
     } catch (string s) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = string("Some kind of accept exception: ") + s;
       GlobalOutput(errStr.c_str());
       break;
     }
 
     // Get the processor
-    shared_ptr<TProcessor> processor = getProcessor(inputProtocol,
-                                                    outputProtocol, client);
+    shared_ptr<TProcessor> processor = getProcessor(inputProtocol, outputProtocol, client);
 
     void* connectionContext = NULL;
     if (eventHandler_) {
@@ -96,9 +115,8 @@ void TSimpleServer::serve() {
         if (eventHandler_) {
           eventHandler_->processContext(connectionContext, client);
         }
-        if (!processor->process(inputProtocol, outputProtocol,
-                                connectionContext) ||
-          // Peek ahead, is the remote side closed?
+        if (!processor->process(inputProtocol, outputProtocol, connectionContext) ||
+            // Peek ahead, is the remote side closed?
             !inputProtocol->getTransport()->peek()) {
           break;
         }
@@ -107,8 +125,7 @@ void TSimpleServer::serve() {
       string errStr = string("TSimpleServer client died: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     } catch (const std::exception& x) {
-      GlobalOutput.printf("TSimpleServer exception: %s: %s",
-                          typeid(x).name(), x.what());
+      GlobalOutput.printf("TSimpleServer exception: %s: %s", typeid(x).name(), x.what());
     } catch (...) {
       GlobalOutput("TSimpleServer uncaught exception.");
     }
@@ -119,22 +136,19 @@ void TSimpleServer::serve() {
     try {
       inputTransport->close();
     } catch (const TTransportException& ttx) {
-      string errStr = string("TSimpleServer input close failed: ")
-        + ttx.what();
+      string errStr = string("TSimpleServer input close failed: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     }
     try {
       outputTransport->close();
     } catch (const TTransportException& ttx) {
-      string errStr = string("TSimpleServer output close failed: ")
-        + ttx.what();
+      string errStr = string("TSimpleServer output close failed: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     }
     try {
       client->close();
     } catch (const TTransportException& ttx) {
-      string errStr = string("TSimpleServer client close failed: ")
-        + ttx.what();
+      string errStr = string("TSimpleServer client close failed: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     }
   }
@@ -142,12 +156,13 @@ void TSimpleServer::serve() {
   if (stop_) {
     try {
       serverTransport_->close();
-    } catch (TTransportException &ttx) {
+    } catch (TTransportException& ttx) {
       string errStr = string("TServerTransport failed on close: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     }
     stop_ = false;
   }
 }
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TSimpleServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TSimpleServer.h b/lib/cpp/src/thrift/server/TSimpleServer.h
index f9e0e2b..967f834 100644
--- a/lib/cpp/src/thrift/server/TSimpleServer.h
+++ b/lib/cpp/src/thrift/server/TSimpleServer.h
@@ -23,7 +23,9 @@
 #include <thrift/server/TServer.h>
 #include <thrift/transport/TServerTransport.h>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 /**
  * This is the most basic simple server. It is single-threaded and runs a
@@ -33,55 +35,54 @@ namespace apache { namespace thrift { namespace server {
  *
  */
 class TSimpleServer : public TServer {
- public:
-  template<typename ProcessorFactory>
-  TSimpleServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& transportFactory,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory, serverTransport, transportFactory,
-            protocolFactory),
-    stop_(false) {}
+public:
+  template <typename ProcessorFactory>
+  TSimpleServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                const boost::shared_ptr<TServerTransport>& serverTransport,
+                const boost::shared_ptr<TTransportFactory>& transportFactory,
+                const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory, serverTransport, transportFactory, protocolFactory), stop_(false) {}
 
-  template<typename Processor>
-  TSimpleServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& transportFactory,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor, serverTransport, transportFactory, protocolFactory),
-    stop_(false) {}
+  template <typename Processor>
+  TSimpleServer(const boost::shared_ptr<Processor>& processor,
+                const boost::shared_ptr<TServerTransport>& serverTransport,
+                const boost::shared_ptr<TTransportFactory>& transportFactory,
+                const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor, serverTransport, transportFactory, protocolFactory), stop_(false) {}
 
-  template<typename ProcessorFactory>
-  TSimpleServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory, serverTransport,
-            inputTransportFactory, outputTransportFactory,
-            inputProtocolFactory, outputProtocolFactory),
-    stop_(false) {}
+  template <typename ProcessorFactory>
+  TSimpleServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                const boost::shared_ptr<TServerTransport>& serverTransport,
+                const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory,
+              serverTransport,
+              inputTransportFactory,
+              outputTransportFactory,
+              inputProtocolFactory,
+              outputProtocolFactory),
+      stop_(false) {}
 
-  template<typename Processor>
-  TSimpleServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor, serverTransport,
-            inputTransportFactory, outputTransportFactory,
-            inputProtocolFactory, outputProtocolFactory),
-    stop_(false) {}
+  template <typename Processor>
+  TSimpleServer(const boost::shared_ptr<Processor>& processor,
+                const boost::shared_ptr<TServerTransport>& serverTransport,
+                const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor,
+              serverTransport,
+              inputTransportFactory,
+              outputTransportFactory,
+              inputProtocolFactory,
+              outputProtocolFactory),
+      stop_(false) {}
 
   ~TSimpleServer() {}
 
@@ -92,11 +93,11 @@ class TSimpleServer : public TServer {
     serverTransport_->interrupt();
   }
 
- protected:
+protected:
   bool stop_;
-
 };
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
index da33ec2..0530d8d 100644
--- a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
+++ b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
@@ -26,7 +26,9 @@
 #include <string>
 #include <iostream>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using boost::shared_ptr;
 using namespace std;
@@ -38,24 +40,21 @@ using namespace apache::thrift::transport;
 class TThreadPoolServer::Task : public Runnable {
 
 public:
-
-  Task(TThreadPoolServer &server,
+  Task(TThreadPoolServer& server,
        shared_ptr<TProcessor> processor,
        shared_ptr<TProtocol> input,
        shared_ptr<TProtocol> output,
-       shared_ptr<TTransport> transport) :
-    server_(server),
-    processor_(processor),
-    input_(input),
-    output_(output),
-    transport_(transport) {
-  }
+       shared_ptr<TTransport> transport)
+    : server_(server),
+      processor_(processor),
+      input_(input),
+      output_(output),
+      transport_(transport) {}
 
   ~Task() {}
 
   void run() {
-    boost::shared_ptr<TServerEventHandler> eventHandler =
-      server_.getEventHandler();
+    boost::shared_ptr<TServerEventHandler> eventHandler = server_.getEventHandler();
     void* connectionContext = NULL;
     if (eventHandler) {
       connectionContext = eventHandler->createContext(input_, output_);
@@ -65,8 +64,8 @@ public:
         if (eventHandler) {
           eventHandler->processContext(connectionContext, transport_);
         }
-        if (!processor_->process(input_, output_, connectionContext) ||
-            !input_->getTransport()->peek()) {
+        if (!processor_->process(input_, output_, connectionContext)
+            || !input_->getTransport()->peek()) {
           break;
         }
       }
@@ -76,11 +75,11 @@ public:
       // string errStr = string("TThreadPoolServer client died: ") + ttx.what();
       // GlobalOutput(errStr.c_str());
     } catch (const std::exception& x) {
-      GlobalOutput.printf("TThreadPoolServer exception %s: %s",
-                          typeid(x).name(), x.what());
+      GlobalOutput.printf("TThreadPoolServer exception %s: %s", typeid(x).name(), x.what());
     } catch (...) {
-      GlobalOutput("TThreadPoolServer, unexpected exception in "
-                   "TThreadPoolServer::Task::run()");
+      GlobalOutput(
+          "TThreadPoolServer, unexpected exception in "
+          "TThreadPoolServer::Task::run()");
     }
 
     if (eventHandler) {
@@ -99,10 +98,9 @@ public:
       string errStr = string("TThreadPoolServer output close failed: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     }
-
   }
 
- private:
+private:
   TServer& server_;
   shared_ptr<TProcessor> processor_;
   shared_ptr<TProtocol> input_;
@@ -110,7 +108,8 @@ public:
   shared_ptr<TTransport> transport_;
 };
 
-TThreadPoolServer::~TThreadPoolServer() {}
+TThreadPoolServer::~TThreadPoolServer() {
+}
 
 void TThreadPoolServer::serve() {
   shared_ptr<TTransport> client;
@@ -144,34 +143,51 @@ void TThreadPoolServer::serve() {
       inputProtocol = inputProtocolFactory_->getProtocol(inputTransport);
       outputProtocol = outputProtocolFactory_->getProtocol(outputTransport);
 
-      shared_ptr<TProcessor> processor = getProcessor(inputProtocol,
-                                                      outputProtocol, client);
+      shared_ptr<TProcessor> processor = getProcessor(inputProtocol, outputProtocol, client);
 
       // Add to threadmanager pool
-      shared_ptr<TThreadPoolServer::Task> task(new TThreadPoolServer::Task(
-            *this, processor, inputProtocol, outputProtocol, client));
+      shared_ptr<TThreadPoolServer::Task> task(
+          new TThreadPoolServer::Task(*this, processor, inputProtocol, outputProtocol, client));
       threadManager_->add(task, timeout_, taskExpiration_);
 
     } catch (TTransportException& ttx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
         string errStr = string("TThreadPoolServer: TServerTransport died on accept: ") + ttx.what();
         GlobalOutput(errStr.c_str());
       }
       continue;
     } catch (TException& tx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = string("TThreadPoolServer: Caught TException: ") + tx.what();
       GlobalOutput(errStr.c_str());
       continue;
     } catch (string s) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = "TThreadPoolServer: Unknown exception: " + s;
       GlobalOutput(errStr.c_str());
       break;
@@ -183,13 +199,12 @@ void TThreadPoolServer::serve() {
     try {
       serverTransport_->close();
       threadManager_->join();
-    } catch (TException &tx) {
+    } catch (TException& tx) {
       string errStr = string("TThreadPoolServer: Exception shutting down: ") + tx.what();
       GlobalOutput(errStr.c_str());
     }
     stop_ = false;
   }
-
 }
 
 int64_t TThreadPoolServer::getTimeout() const {
@@ -207,5 +222,6 @@ int64_t TThreadPoolServer::getTaskExpiration() const {
 void TThreadPoolServer::setTaskExpiration(int64_t value) {
   taskExpiration_ = value;
 }
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TThreadPoolServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.h b/lib/cpp/src/thrift/server/TThreadPoolServer.h
index 8a1fc16..ad7e7ef 100644
--- a/lib/cpp/src/thrift/server/TThreadPoolServer.h
+++ b/lib/cpp/src/thrift/server/TThreadPoolServer.h
@@ -26,7 +26,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using apache::thrift::concurrency::ThreadManager;
 using apache::thrift::protocol::TProtocolFactory;
@@ -34,73 +36,74 @@ using apache::thrift::transport::TServerTransport;
 using apache::thrift::transport::TTransportFactory;
 
 class TThreadPoolServer : public TServer {
- public:
+public:
   class Task;
 
-  template<typename ProcessorFactory>
-  TThreadPoolServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& transportFactory,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      const boost::shared_ptr<ThreadManager>& threadManager,
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory, serverTransport, transportFactory,
-            protocolFactory),
-    threadManager_(threadManager),
-    stop_(false),
-    timeout_(0),
-    taskExpiration_(0) {}
-
-  template<typename Processor>
-  TThreadPoolServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& transportFactory,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      const boost::shared_ptr<ThreadManager>& threadManager,
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor, serverTransport, transportFactory, protocolFactory),
-    threadManager_(threadManager),
-    stop_(false),
-    timeout_(0),
-    taskExpiration_(0) {}
-
-  template<typename ProcessorFactory>
-  TThreadPoolServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      const boost::shared_ptr<ThreadManager>& threadManager,
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory, serverTransport,
-            inputTransportFactory, outputTransportFactory,
-            inputProtocolFactory, outputProtocolFactory),
-    threadManager_(threadManager),
-    stop_(false),
-    timeout_(0),
-    taskExpiration_(0) {}
-
-  template<typename Processor>
-  TThreadPoolServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      const boost::shared_ptr<ThreadManager>& threadManager,
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor, serverTransport,
-            inputTransportFactory, outputTransportFactory,
-            inputProtocolFactory, outputProtocolFactory),
-    threadManager_(threadManager),
-    stop_(false),
-    timeout_(0),
-    taskExpiration_(0) {}
+  template <typename ProcessorFactory>
+  TThreadPoolServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                    const boost::shared_ptr<TServerTransport>& serverTransport,
+                    const boost::shared_ptr<TTransportFactory>& transportFactory,
+                    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                    const boost::shared_ptr<ThreadManager>& threadManager,
+                    THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory, serverTransport, transportFactory, protocolFactory),
+      threadManager_(threadManager),
+      stop_(false),
+      timeout_(0),
+      taskExpiration_(0) {}
+
+  template <typename Processor>
+  TThreadPoolServer(const boost::shared_ptr<Processor>& processor,
+                    const boost::shared_ptr<TServerTransport>& serverTransport,
+                    const boost::shared_ptr<TTransportFactory>& transportFactory,
+                    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                    const boost::shared_ptr<ThreadManager>& threadManager,
+                    THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor, serverTransport, transportFactory, protocolFactory),
+      threadManager_(threadManager),
+      stop_(false),
+      timeout_(0),
+      taskExpiration_(0) {}
+
+  template <typename ProcessorFactory>
+  TThreadPoolServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                    const boost::shared_ptr<TServerTransport>& serverTransport,
+                    const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                    const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                    const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                    const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                    const boost::shared_ptr<ThreadManager>& threadManager,
+                    THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory,
+              serverTransport,
+              inputTransportFactory,
+              outputTransportFactory,
+              inputProtocolFactory,
+              outputProtocolFactory),
+      threadManager_(threadManager),
+      stop_(false),
+      timeout_(0),
+      taskExpiration_(0) {}
+
+  template <typename Processor>
+  TThreadPoolServer(const boost::shared_ptr<Processor>& processor,
+                    const boost::shared_ptr<TServerTransport>& serverTransport,
+                    const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                    const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                    const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                    const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                    const boost::shared_ptr<ThreadManager>& threadManager,
+                    THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor,
+              serverTransport,
+              inputTransportFactory,
+              outputTransportFactory,
+              inputProtocolFactory,
+              outputProtocolFactory),
+      threadManager_(threadManager),
+      stop_(false),
+      timeout_(0),
+      taskExpiration_(0) {}
 
   virtual ~TThreadPoolServer();
 
@@ -119,8 +122,7 @@ class TThreadPoolServer : public TServer {
 
   virtual void setTaskExpiration(int64_t value);
 
- protected:
-
+protected:
   boost::shared_ptr<ThreadManager> threadManager_;
 
   volatile bool stop_;
@@ -128,9 +130,9 @@ class TThreadPoolServer : public TServer {
   volatile int64_t timeout_;
 
   volatile int64_t taskExpiration_;
-
 };
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TTHREADPOOLSERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TThreadedServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TThreadedServer.cpp b/lib/cpp/src/thrift/server/TThreadedServer.cpp
index 909c3ce..929ed86 100644
--- a/lib/cpp/src/thrift/server/TThreadedServer.cpp
+++ b/lib/cpp/src/thrift/server/TThreadedServer.cpp
@@ -28,7 +28,9 @@
 #include <unistd.h>
 #endif
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using boost::shared_ptr;
 using namespace std;
@@ -37,27 +39,24 @@ using namespace apache::thrift::protocol;
 using namespace apache::thrift::transport;
 using namespace apache::thrift::concurrency;
 
-class TThreadedServer::Task: public Runnable {
+class TThreadedServer::Task : public Runnable {
 
 public:
-
   Task(TThreadedServer& server,
        shared_ptr<TProcessor> processor,
        shared_ptr<TProtocol> input,
        shared_ptr<TProtocol> output,
-       shared_ptr<TTransport> transport) :
-    server_(server),
-    processor_(processor),
-    input_(input),
-    output_(output),
-    transport_(transport) {
-  }
+       shared_ptr<TTransport> transport)
+    : server_(server),
+      processor_(processor),
+      input_(input),
+      output_(output),
+      transport_(transport) {}
 
   ~Task() {}
 
   void run() {
-    boost::shared_ptr<TServerEventHandler> eventHandler =
-      server_.getEventHandler();
+    boost::shared_ptr<TServerEventHandler> eventHandler = server_.getEventHandler();
     void* connectionContext = NULL;
     if (eventHandler) {
       connectionContext = eventHandler->createContext(input_, output_);
@@ -67,8 +66,8 @@ public:
         if (eventHandler) {
           eventHandler->processContext(connectionContext, transport_);
         }
-        if (!processor_->process(input_, output_, connectionContext) ||
-            !input_->getTransport()->peek()) {
+        if (!processor_->process(input_, output_, connectionContext)
+            || !input_->getTransport()->peek()) {
           break;
         }
       }
@@ -77,9 +76,8 @@ public:
         string errStr = string("TThreadedServer client died: ") + ttx.what();
         GlobalOutput(errStr.c_str());
       }
-    } catch (const std::exception &x) {
-      GlobalOutput.printf("TThreadedServer exception: %s: %s",
-                          typeid(x).name(), x.what());
+    } catch (const std::exception& x) {
+      GlobalOutput.printf("TThreadedServer exception: %s: %s", typeid(x).name(), x.what());
     } catch (...) {
       GlobalOutput("TThreadedServer uncaught exception.");
     }
@@ -108,10 +106,9 @@ public:
         server_.tasksMonitor_.notify();
       }
     }
-
   }
 
- private:
+private:
   TThreadedServer& server_;
   friend class TThreadedServer;
 
@@ -129,7 +126,8 @@ void TThreadedServer::init() {
   }
 }
 
-TThreadedServer::~TThreadedServer() {}
+TThreadedServer::~TThreadedServer() {
+}
 
 void TThreadedServer::serve() {
 
@@ -164,22 +162,16 @@ void TThreadedServer::serve() {
       inputProtocol = inputProtocolFactory_->getProtocol(inputTransport);
       outputProtocol = outputProtocolFactory_->getProtocol(outputTransport);
 
-      shared_ptr<TProcessor> processor = getProcessor(inputProtocol,
-                                                      outputProtocol, client);
+      shared_ptr<TProcessor> processor = getProcessor(inputProtocol, outputProtocol, client);
 
-      TThreadedServer::Task* task = new TThreadedServer::Task(*this,
-                                                              processor,
-                                                              inputProtocol,
-                                                              outputProtocol,
-                                                              client);
+      TThreadedServer::Task* task
+          = new TThreadedServer::Task(*this, processor, inputProtocol, outputProtocol, client);
 
       // Create a task
-      shared_ptr<Runnable> runnable =
-        shared_ptr<Runnable>(task);
+      shared_ptr<Runnable> runnable = shared_ptr<Runnable>(task);
 
       // Create a thread for this task
-      shared_ptr<Thread> thread =
-        shared_ptr<Thread>(threadFactory_->newThread(runnable));
+      shared_ptr<Thread> thread = shared_ptr<Thread>(threadFactory_->newThread(runnable));
 
       // Insert thread into the set of threads
       {
@@ -191,25 +183,43 @@ void TThreadedServer::serve() {
       thread->start();
 
     } catch (TTransportException& ttx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
         string errStr = string("TThreadedServer: TServerTransport died on accept: ") + ttx.what();
         GlobalOutput(errStr.c_str());
       }
       continue;
     } catch (TException& tx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = string("TThreadedServer: Caught TException: ") + tx.what();
       GlobalOutput(errStr.c_str());
       continue;
     } catch (string s) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = "TThreadedServer: Unknown exception: " + s;
       GlobalOutput(errStr.c_str());
       break;
@@ -220,7 +230,7 @@ void TThreadedServer::serve() {
   if (stop_) {
     try {
       serverTransport_->close();
-    } catch (TException &tx) {
+    } catch (TException& tx) {
       string errStr = string("TThreadedServer: Exception shutting down: ") + tx.what();
       GlobalOutput(errStr.c_str());
     }
@@ -229,13 +239,13 @@ void TThreadedServer::serve() {
       while (!tasks_.empty()) {
         tasksMonitor_.wait();
       }
-    } catch (TException &tx) {
+    } catch (TException& tx) {
       string errStr = string("TThreadedServer: Exception joining workers: ") + tx.what();
       GlobalOutput(errStr.c_str());
     }
     stop_ = false;
   }
-
 }
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TThreadedServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TThreadedServer.h b/lib/cpp/src/thrift/server/TThreadedServer.h
index f965fcd..2b1f757 100644
--- a/lib/cpp/src/thrift/server/TThreadedServer.h
+++ b/lib/cpp/src/thrift/server/TThreadedServer.h
@@ -27,7 +27,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using apache::thrift::TProcessor;
 using apache::thrift::transport::TServerTransport;
@@ -37,17 +39,17 @@ using apache::thrift::concurrency::ThreadFactory;
 
 class TThreadedServer : public TServer {
 
- public:
+public:
   class Task;
 
-  template<typename ProcessorFactory>
+  template <typename ProcessorFactory>
   TThreadedServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
                   const boost::shared_ptr<TServerTransport>& serverTransport,
                   const boost::shared_ptr<TTransportFactory>& transportFactory,
                   const boost::shared_ptr<TProtocolFactory>& protocolFactory,
                   THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory));
 
-  template<typename ProcessorFactory>
+  template <typename ProcessorFactory>
   TThreadedServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
                   const boost::shared_ptr<TServerTransport>& serverTransport,
                   const boost::shared_ptr<TTransportFactory>& transportFactory,
@@ -55,14 +57,14 @@ class TThreadedServer : public TServer {
                   const boost::shared_ptr<ThreadFactory>& threadFactory,
                   THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory));
 
-  template<typename Processor>
+  template <typename Processor>
   TThreadedServer(const boost::shared_ptr<Processor>& processor,
                   const boost::shared_ptr<TServerTransport>& serverTransport,
                   const boost::shared_ptr<TTransportFactory>& transportFactory,
                   const boost::shared_ptr<TProtocolFactory>& protocolFactory,
                   THRIFT_OVERLOAD_IF(Processor, TProcessor));
 
-  template<typename Processor>
+  template <typename Processor>
   TThreadedServer(const boost::shared_ptr<Processor>& processor,
                   const boost::shared_ptr<TServerTransport>& serverTransport,
                   const boost::shared_ptr<TTransportFactory>& transportFactory,
@@ -79,7 +81,7 @@ class TThreadedServer : public TServer {
     serverTransport_->interrupt();
   }
 
- protected:
+protected:
   void init();
 
   boost::shared_ptr<ThreadFactory> threadFactory_;
@@ -87,59 +89,53 @@ class TThreadedServer : public TServer {
 
   Monitor tasksMonitor_;
   std::set<Task*> tasks_;
-
 };
 
-template<typename ProcessorFactory>
-TThreadedServer::TThreadedServer(
-    const boost::shared_ptr<ProcessorFactory>& processorFactory,
-    const boost::shared_ptr<TServerTransport>& serverTransport,
-    const boost::shared_ptr<TTransportFactory>& transportFactory,
-    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-    THRIFT_OVERLOAD_IF_DEFN(ProcessorFactory, TProcessorFactory)) :
-  TServer(processorFactory, serverTransport, transportFactory,
-          protocolFactory) {
+template <typename ProcessorFactory>
+TThreadedServer::TThreadedServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                                 const boost::shared_ptr<TServerTransport>& serverTransport,
+                                 const boost::shared_ptr<TTransportFactory>& transportFactory,
+                                 const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                                 THRIFT_OVERLOAD_IF_DEFN(ProcessorFactory, TProcessorFactory))
+  : TServer(processorFactory, serverTransport, transportFactory, protocolFactory) {
   init();
 }
 
-template<typename ProcessorFactory>
-TThreadedServer::TThreadedServer(
-    const boost::shared_ptr<ProcessorFactory>& processorFactory,
-    const boost::shared_ptr<TServerTransport>& serverTransport,
-    const boost::shared_ptr<TTransportFactory>& transportFactory,
-    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-    const boost::shared_ptr<ThreadFactory>& threadFactory,
-    THRIFT_OVERLOAD_IF_DEFN(ProcessorFactory, TProcessorFactory)) :
-  TServer(processorFactory, serverTransport, transportFactory,
-          protocolFactory),
-  threadFactory_(threadFactory) {
+template <typename ProcessorFactory>
+TThreadedServer::TThreadedServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                                 const boost::shared_ptr<TServerTransport>& serverTransport,
+                                 const boost::shared_ptr<TTransportFactory>& transportFactory,
+                                 const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                                 const boost::shared_ptr<ThreadFactory>& threadFactory,
+                                 THRIFT_OVERLOAD_IF_DEFN(ProcessorFactory, TProcessorFactory))
+  : TServer(processorFactory, serverTransport, transportFactory, protocolFactory),
+    threadFactory_(threadFactory) {
   init();
 }
 
-template<typename Processor>
-TThreadedServer::TThreadedServer(
-    const boost::shared_ptr<Processor>& processor,
-    const boost::shared_ptr<TServerTransport>& serverTransport,
-    const boost::shared_ptr<TTransportFactory>& transportFactory,
-    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-    THRIFT_OVERLOAD_IF_DEFN(Processor, TProcessor)) :
-  TServer(processor, serverTransport, transportFactory, protocolFactory) {
+template <typename Processor>
+TThreadedServer::TThreadedServer(const boost::shared_ptr<Processor>& processor,
+                                 const boost::shared_ptr<TServerTransport>& serverTransport,
+                                 const boost::shared_ptr<TTransportFactory>& transportFactory,
+                                 const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                                 THRIFT_OVERLOAD_IF_DEFN(Processor, TProcessor))
+  : TServer(processor, serverTransport, transportFactory, protocolFactory) {
   init();
 }
 
-template<typename Processor>
-TThreadedServer::TThreadedServer(
-    const boost::shared_ptr<Processor>& processor,
-    const boost::shared_ptr<TServerTransport>& serverTransport,
-    const boost::shared_ptr<TTransportFactory>& transportFactory,
-    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-    const boost::shared_ptr<ThreadFactory>& threadFactory,
-    THRIFT_OVERLOAD_IF_DEFN(Processor, TProcessor)) :
-  TServer(processor, serverTransport, transportFactory, protocolFactory),
-  threadFactory_(threadFactory) {
+template <typename Processor>
+TThreadedServer::TThreadedServer(const boost::shared_ptr<Processor>& processor,
+                                 const boost::shared_ptr<TServerTransport>& serverTransport,
+                                 const boost::shared_ptr<TTransportFactory>& transportFactory,
+                                 const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                                 const boost::shared_ptr<ThreadFactory>& threadFactory,
+                                 THRIFT_OVERLOAD_IF_DEFN(Processor, TProcessor))
+  : TServer(processor, serverTransport, transportFactory, protocolFactory),
+    threadFactory_(threadFactory) {
   init();
 }
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TTHREADEDSERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/thrift-config.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/thrift-config.h b/lib/cpp/src/thrift/thrift-config.h
old mode 100755
new mode 100644
index b1bcccb..d648706
--- a/lib/cpp/src/thrift/thrift-config.h
+++ b/lib/cpp/src/thrift/thrift-config.h
@@ -18,7 +18,7 @@
  */
 
 #ifdef _WIN32
-# include <thrift/windows/config.h>
+#include <thrift/windows/config.h>
 #else
-# include <thrift/config.h>
+#include <thrift/config.h>
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/PlatformSocket.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/PlatformSocket.h b/lib/cpp/src/thrift/transport/PlatformSocket.h
index d28978e..96a3da3 100644
--- a/lib/cpp/src/thrift/transport/PlatformSocket.h
+++ b/lib/cpp/src/thrift/transport/PlatformSocket.h
@@ -17,6 +17,8 @@
  * under the License.
  */
 
+// clang-format off
+
 #ifndef _THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
 #  define _THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TBufferTransports.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.cpp b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
index 15d8f59..25adb23 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.cpp
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
@@ -24,8 +24,9 @@
 
 using std::string;
 
-namespace apache { namespace thrift { namespace transport {
-
+namespace apache {
+namespace thrift {
+namespace transport {
 
 uint32_t TBufferedTransport::readSlow(uint8_t* buf, uint32_t len) {
   uint32_t have = static_cast<uint32_t>(rBound_ - rBase_);
@@ -85,7 +86,7 @@ void TBufferedTransport::writeSlow(const uint8_t* buf, uint32_t len) {
   // The case where we have to do two syscalls.
   // This case also covers the case where the buffer is empty,
   // but it is clearer (I think) to think of it as two separate cases.
-  if ((have_bytes + len >= 2*wBufSize_) || (have_bytes == 0)) {
+  if ((have_bytes + len >= 2 * wBufSize_) || (have_bytes == 0)) {
     // TODO(dreiss): writev
     if (have_bytes > 0) {
       transport_->write(wBuf_.get(), have_bytes);
@@ -109,14 +110,14 @@ void TBufferedTransport::writeSlow(const uint8_t* buf, uint32_t len) {
 }
 
 const uint8_t* TBufferedTransport::borrowSlow(uint8_t* buf, uint32_t* len) {
-  (void) buf;
-  (void) len;
+  (void)buf;
+  (void)len;
   // Simply return NULL.  We don't know if there is actually data available on
   // the underlying transport, so calling read() might block.
   return NULL;
 }
 
-void TBufferedTransport::flush()  {
+void TBufferedTransport::flush() {
   // Write out any data waiting in the write buffer.
   uint32_t have_bytes = static_cast<uint32_t>(wBase_ - wBuf_.get());
   if (have_bytes > 0) {
@@ -131,7 +132,6 @@ void TBufferedTransport::flush()  {
   transport_->flush();
 }
 
-
 uint32_t TFramedTransport::readSlow(uint8_t* buf, uint32_t len) {
   uint32_t want = len;
   uint32_t have = static_cast<uint32_t>(rBound_ - rBase_);
@@ -179,9 +179,8 @@ bool TFramedTransport::readFrame() {
   uint32_t size_bytes_read = 0;
   while (size_bytes_read < sizeof(sz)) {
     uint8_t* szp = reinterpret_cast<uint8_t*>(&sz) + size_bytes_read;
-    uint32_t bytes_read = transport_->read(
-      szp,
-      static_cast<uint32_t>(sizeof(sz)) - size_bytes_read);
+    uint32_t bytes_read
+        = transport_->read(szp, static_cast<uint32_t>(sizeof(sz)) - size_bytes_read);
     if (bytes_read == 0) {
       if (size_bytes_read == 0) {
         // EOF before any data was read.
@@ -218,7 +217,7 @@ void TFramedTransport::writeSlow(const uint8_t* buf, uint32_t len) {
   uint32_t new_size = wBufSize_;
   if (len + have < have /* overflow */ || len + have > 0x7fffffff) {
     throw TTransportException(TTransportException::BAD_ARGS,
-        "Attempted to write over 2 GB to TFramedTransport.");
+                              "Attempted to write over 2 GB to TFramedTransport.");
   }
   while (new_size < len + have) {
     new_size = new_size > 0 ? new_size * 2 : 1;
@@ -244,7 +243,7 @@ void TFramedTransport::writeSlow(const uint8_t* buf, uint32_t len) {
   wBase_ += len;
 }
 
-void TFramedTransport::flush()  {
+void TFramedTransport::flush() {
   int32_t sz_hbo, sz_nbo;
   assert(wBufSize_ > sizeof(sz_nbo));
 
@@ -261,9 +260,7 @@ void TFramedTransport::flush()  {
     wBase_ = wBuf_.get() + sizeof(sz_nbo);
 
     // Write size and frame body.
-    transport_->write(
-      wBuf_.get(),
-      static_cast<uint32_t>(sizeof(sz_nbo))+sz_hbo);
+    transport_->write(wBuf_.get(), static_cast<uint32_t>(sizeof(sz_nbo)) + sz_hbo);
   }
 
   // Flush the underlying transport.
@@ -286,8 +283,8 @@ uint32_t TFramedTransport::writeEnd() {
 }
 
 const uint8_t* TFramedTransport::borrowSlow(uint8_t* buf, uint32_t* len) {
-  (void) buf;
-  (void) len;
+  (void)buf;
+  (void)len;
   // Don't try to be clever with shifting buffers.
   // If the fast path failed let the protocol use its slow path.
   // Besides, who is going to try to borrow across messages?
@@ -299,9 +296,9 @@ uint32_t TFramedTransport::readEnd() {
   uint32_t bytes_read = static_cast<uint32_t>(rBound_ - rBuf_.get() + sizeof(uint32_t));
 
   if (rBufSize_ > bufReclaimThresh_) {
-      rBufSize_ = 0;
-      rBuf_.reset();
-      setReadBuffer(rBuf_.get(), rBufSize_);
+    rBufSize_ = 0;
+    rBuf_.reset();
+    setReadBuffer(rBuf_.get(), rBufSize_);
   }
 
   return bytes_read;
@@ -398,7 +395,7 @@ void TMemoryBuffer::wroteBytes(uint32_t len) {
 }
 
 const uint8_t* TMemoryBuffer::borrowSlow(uint8_t* buf, uint32_t* len) {
-  (void) buf;
+  (void)buf;
   rBound_ = wBase_;
   if (available_read() >= *len) {
     *len = available_read();
@@ -406,5 +403,6 @@ const uint8_t* TMemoryBuffer::borrowSlow(uint8_t* buf, uint32_t* len) {
   }
   return NULL;
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport