You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2018/03/11 14:58:21 UTC
thrift git commit: THRIFT-4515: fix up nonblocking options and enable
ssl for nonblocking in cpp server cross Client: cpp
Repository: thrift
Updated Branches:
refs/heads/master fe50feae7 -> 70b33fb6b
THRIFT-4515: fix up nonblocking options and enable ssl for nonblocking in cpp server cross
Client: cpp
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/70b33fb6
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/70b33fb6
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/70b33fb6
Branch: refs/heads/master
Commit: 70b33fb6b48d62859a048cac1bec79cfadb2f310
Parents: fe50fea
Author: James E. King III <jk...@apache.org>
Authored: Sun Mar 11 10:57:10 2018 -0400
Committer: James E. King III <jk...@apache.org>
Committed: Sun Mar 11 10:57:56 2018 -0400
----------------------------------------------------------------------
test/cpp/src/TestServer.cpp | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/70b33fb6/test/cpp/src/TestServer.cpp
----------------------------------------------------------------------
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 78b0a74..6b4df7d 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -33,6 +33,7 @@
#include <thrift/server/TThreadedServer.h>
#include <thrift/transport/THttpServer.h>
#include <thrift/transport/THttpTransport.h>
+#include <thrift/transport/TNonblockingSSLServerSocket.h>
#include <thrift/transport/TNonblockingServerSocket.h>
#include <thrift/transport/TSSLServerSocket.h>
#include <thrift/transport/TSSLSocket.h>
@@ -676,7 +677,9 @@ int main(int argc, char** argv) {
sslSocketFactory->loadCertificate(certPath.c_str());
sslSocketFactory->loadPrivateKey(keyPath.c_str());
sslSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
- serverSocket = stdcxx::shared_ptr<TServerSocket>(new TSSLServerSocket(port, sslSocketFactory));
+ if (server_type != "nonblocking") {
+ serverSocket = stdcxx::shared_ptr<TServerSocket>(new TSSLServerSocket(port, sslSocketFactory));
+ }
} else {
if (domain_socket != "") {
if (abstract_namespace) {
@@ -738,13 +741,11 @@ int main(int argc, char** argv) {
server.reset(new TSimpleServer(testProcessor, serverSocket, transportFactory, protocolFactory));
} else if (server_type == "thread-pool") {
- stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers);
-
stdcxx::shared_ptr<PlatformThreadFactory> threadFactory
= stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+ stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers);
threadManager->threadFactory(threadFactory);
-
threadManager->start();
server.reset(new TThreadPoolServer(testProcessor,
@@ -753,7 +754,6 @@ int main(int argc, char** argv) {
protocolFactory,
threadManager));
} else if (server_type == "threaded") {
-
server.reset(
new TThreadedServer(testProcessor, serverSocket, transportFactory, protocolFactory));
} else if (server_type == "nonblocking") {
@@ -769,10 +769,15 @@ int main(int argc, char** argv) {
// provide a stop method.
TEvhttpServer nonblockingServer(testBufferProcessor, port);
nonblockingServer.serve();
- } else {
- stdcxx::shared_ptr<transport::TNonblockingServerSocket> nbSocket;
- nbSocket.reset(new transport::TNonblockingServerSocket(port));
+ } else if (transport_type == "framed") {
+ stdcxx::shared_ptr<transport::TNonblockingServerTransport> nbSocket;
+ nbSocket.reset(
+ ssl ? new transport::TNonblockingSSLServerSocket(port, sslSocketFactory)
+ : new transport::TNonblockingServerSocket(port));
server.reset(new TNonblockingServer(testProcessor, protocolFactory, nbSocket));
+ } else {
+ cerr << "server-type nonblocking requires transport of http or framed" << endl;
+ exit(1);
}
}
@@ -789,13 +794,11 @@ int main(int argc, char** argv) {
= factory.newThread(serverThreadRunner);
thread->start();
- // HACK: cross language test suite is unable to handle cin properly
- // that's why we stay in a endless loop here
+ // THRIFT-4515: this needs to be improved
while (1) {
+ sleep(1); // do something other than chew up CPU like crazy
}
- // FIXME: find another way to stop the server (e.g. a signal)
- // cout<<"Press enter to stop the server."<<endl;
- // cin.ignore(); //wait until a key is pressed
+ // NOTREACHED
server->stop();
thread->join();