[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 32/50: controlport: moving the generation o
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 32/50: controlport: moving the generation of the Thrift endpoint string to the application_started() function. |
Date: |
Wed, 15 Apr 2015 21:07:55 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit de96353ab2b27f251909ec9a69f336f133899011
Author: Nate Goergen <address@hidden>
Date: Wed Mar 4 17:38:53 2015 -0600
controlport: moving the generation of the Thrift endpoint string to the
application_started() function.
Includes moving the call that logs the generated endpoint.
This allows the application_base::kickoff() function to wait until the
Thrift runtime publishes the port selected by bind(), when a
pseudorandom / unused port number is configured (i.e. port=0, the
default setting). Once bind()'s final port number is available, the
endpoint string may be generated and the ControlPort Thrift interface
may be started.
---
.../include/gnuradio/thrift_application_base.h | 29 +++++++++++-------
.../include/gnuradio/thrift_server_template.h | 19 ------------
.../controlport/thrift/rpcserver_booter_thrift.cc | 34 +++++++++++++++++++++-
3 files changed, 51 insertions(+), 31 deletions(-)
diff --git a/gnuradio-runtime/include/gnuradio/thrift_application_base.h
b/gnuradio-runtime/include/gnuradio/thrift_application_base.h
index 4dc56a1..b957c5e 100644
--- a/gnuradio-runtime/include/gnuradio/thrift_application_base.h
+++ b/gnuradio-runtime/include/gnuradio/thrift_application_base.h
@@ -106,10 +106,7 @@ thrift_application_base<TserverBase,
TserverClass>::thrift_application_base(Tser
GR_LOG_DEBUG(d_debug_logger, "thrift_application_base: ctor");
//std::cerr << "thrift_application_base: ctor" << std::endl;
- d_is_running = false;
d_this = _this;
-
- //d_application->d_thriftserver = d_this->d_thriftserver;
}
template<typename TserverBase, typename TserverClass>
@@ -123,10 +120,26 @@ void thrift_application_base<TserverBase,
TserverClass>::kickoff()
thrift_application_common::d_thread = boost::shared_ptr<gr::thread::thread>
(new
gr::thread::thread(boost::bind(&thrift_application_base::start_thrift,
d_this)));
+ ::timespec timer_ts, rem_ts;
+ timer_ts.tv_sec = 0; timer_ts.tv_nsec =
THRIFTAPPLICATION_ACTIVATION_TIMEOUT_MS*1000;
+
+ int iter = 0;
+ while(!d_this->application_started()) {
+#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+ ::Sleep(timer_ts.tv_nsec / 1000000);
+#else
+ ::nanosleep(&timer_ts, &rem_ts);
+#endif
+ if(!d_this->application_started())
+ std::cout << "@";
+ if(iter++ > 100) {
+ std::cout << "thrift_application_base::kickoff(), timeout waiting to
port number might have failed?!" << std::endl;;
+ break;
+ }
+ }
+
run_once = true;
}
-
- return;
}
@@ -154,10 +167,4 @@ TserverBase* thrift_application_base<TserverBase,
TserverClass>::i()
return d_this->i_impl();
}
-template<typename TserverBase, typename TImplClass>
-bool thrift_application_base<TserverBase, TImplClass>::application_started()
-{
- return d_is_running;
-}
-
#endif
diff --git a/gnuradio-runtime/include/gnuradio/thrift_server_template.h
b/gnuradio-runtime/include/gnuradio/thrift_server_template.h
index 0bf4ac2..1635642 100644
--- a/gnuradio-runtime/include/gnuradio/thrift_server_template.h
+++ b/gnuradio-runtime/include/gnuradio/thrift_server_template.h
@@ -37,9 +37,6 @@
#include <thrift/transport/TBufferTransports.h>
#include "thrift/ControlPort.h"
-//#include <netdb.h>
-#include <boost/asio/ip/host_name.hpp>
-
using namespace apache;
namespace {
@@ -171,22 +168,6 @@ TserverBase* thrift_server_template<TserverBase,
TserverClass, TImplClass, TThri
{
//std::cerr << "thrift_server_template: i_impl" << std::endl;
- // Determine the hostname of this host
- const std::string boost_hostname(boost::asio::ip::host_name());
-
- // Define the endpoint
- thrift::transport::TServerTransport *thetransport =
- thrift_application_base<TserverBase,
TImplClass>::d_thriftserver->getServerTransport().get();
-
- // Determine the specified endpoint port number, or the port number selected
by bind() if
- // ControlPort is configured to listen on port 0 (the default)
- int used_port = ((thrift::transport::TServerSocket*)thetransport)->getPort();
- std::string endpoint = boost::str(boost::format("-h %1% -p %2%") %
boost_hostname % used_port);
- //std::cout << "Thrift endpoint: " << endpoint << " boost hostname: " <<
boost_hostname << std::endl;
- thrift_application_base<TserverBase,
TImplClass>::d_this->set_endpoint(endpoint);
-
- GR_LOG_INFO(logger, "Apache Thrift: " + endpoint);
-
return d_server;
}
diff --git a/gnuradio-runtime/lib/controlport/thrift/rpcserver_booter_thrift.cc
b/gnuradio-runtime/lib/controlport/thrift/rpcserver_booter_thrift.cc
index b76ce77..095db2e 100644
--- a/gnuradio-runtime/lib/controlport/thrift/rpcserver_booter_thrift.cc
+++ b/gnuradio-runtime/lib/controlport/thrift/rpcserver_booter_thrift.cc
@@ -23,6 +23,8 @@
#include <gnuradio/rpcserver_thrift.h>
#include <gnuradio/rpcserver_booter_thrift.h>
+#include <boost/asio/ip/host_name.hpp>
+
namespace {
static const char* const CONTROL_PORT_CLASS("thrift");
static const char* const CONTROL_PORT_NAME("ControlPort");
@@ -96,7 +98,37 @@ void thrift_application_base<TserverBase,
TserverClass>::start_thrift()
//std::cerr << "thrift_application_base: start_thrift" << std::endl;
GR_LOG_DEBUG(d_debug_logger, "thrift_application_base: start server");
- d_is_running = true;
d_thriftserver->serve();
GR_LOG_DEBUG(d_debug_logger, "thrift_application_base: server started");
}
+
+
+template<typename TserverBase, typename TserverClass>
+bool thrift_application_base<TserverBase, TserverClass>::application_started()
+{
+ if (d_is_running) return true;
+
+ bool result(false);
+ // Define the endpoint
+ apache::thrift::transport::TServerTransport *thetransport =
+ d_thriftserver->getServerTransport().get();
+
+ // Determine the specified endpoint port number, or the port number selected
by bind() if
+ // ControlPort is configured to listen on port 0 (the default)
+ int used_port =
((apache::thrift::transport::TServerSocket*)thetransport)->getPort();
+
+ if (used_port > 0) {
+ // Determine the hostname of this host
+ const std::string boost_hostname(boost::asio::ip::host_name());
+
+ std::string endpoint = boost::str(boost::format("-h %1% -p %2%") %
boost_hostname % used_port);
+ //std::cout << "Thrift endpoint: " << endpoint << " boost hostname: " <<
boost_hostname << std::endl;
+ set_endpoint(endpoint);
+
+ GR_LOG_INFO(logger, "Apache Thrift: " + endpoint);
+ d_is_running = true;
+ result = true;
+ }
+
+ return result;
+}
- [Commit-gnuradio] [gnuradio] 45/50: controlport: ensure proper ctrlport shutdown., (continued)
- [Commit-gnuradio] [gnuradio] 45/50: controlport: ensure proper ctrlport shutdown., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 08/50: controlport: adding abstraction layer for the controlport backends; support thrift currently., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 25/50: controlport: fixing up some issues; generate thrift sources into thrift subdir., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 16/50: controlport: switching rpcpmtconverter::to_pmt() to To_PMT singleton, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 40/50: controlport: documentation cleanup, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 10/50: controlport: more cleanup of python code to help generalize the interface, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 38/50: controlport: cleanup, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 41/50: controlport: cmake fixes to FindThrift for when thrift is not installed., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 43/50: controlport: more documentation and linking info., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 37/50: controlport: Some documentation, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 32/50: controlport: moving the generation of the Thrift endpoint string to the application_started() function.,
git <=
- [Commit-gnuradio] [gnuradio] 42/50: controlport: QA needs to get host and port out of the endpoint., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 27/50: controlport: cleaning up; trying to handle shutdown better., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 19/50: controlport: simple style editing., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 36/50: controlport: renamed some functions for clairity, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 50/50: Merge branch 'ctrlport', git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 26/50: docs: adding in info on ControlPort and Thrift., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 49/50: cmake: fix case for ctrlport when no backends installed, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 12/50: controlport: reorg abstraction layers for RPC connections., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 46/50: controlport: avoid copy of outknobs (a temporary)., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 47/50: controlport: cleaner, more robust interface for buffer gets., git, 2015/04/16