commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 31/50: controlport: moving the logger call


From: git
Subject: [Commit-gnuradio] [gnuradio] 31/50: controlport: moving the logger call that publishes Thrift's endpoint to i_impl().
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 8d72b2e7d15444c91b5d3968756eab8d943dcb3b
Author: Nate Goergen <address@hidden>
Date:   Tue Mar 3 22:01:33 2015 -0600

    controlport: moving the logger call that publishes Thrift's endpoint to 
i_impl().
    
    Using to verify that the hostname and OS selected port number are
    eventually determined correctly.
    
    However, as i_imp() may be called many times throughout the lifetime
    of a flowgraph, this can't be the final place where the endpoint is
    generated. It appears that the initial calls within the first few
    milliseconds of TServerSocket creation may return an incorrect port
    number when getPort() is queried (i.e. 0 if a randomly open / selected
    port is requested vs. the selected port number).
    
    Endpoint string generation and the call to the logger should probably
    be moved to a function that executes only once after the results from
    getPort() have had time to settle.
---
 .../include/gnuradio/thrift_server_template.h      | 27 ++++++++--------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/gnuradio-runtime/include/gnuradio/thrift_server_template.h 
b/gnuradio-runtime/include/gnuradio/thrift_server_template.h
index 9972dd2..0bf4ac2 100644
--- a/gnuradio-runtime/include/gnuradio/thrift_server_template.h
+++ b/gnuradio-runtime/include/gnuradio/thrift_server_template.h
@@ -158,10 +158,6 @@ thrift_server_template<TserverBase, TserverClass, 
TImplClass, TThriftClass>::thr
                                             threadManager);
   }
 
-  int used_port = 
((thrift::transport::TServerSocket*)serverTransport.get())->getPort();
-  std::string endpoint = boost::str(boost::format("%1% -p %2%") % "127.0.0.1" 
% used_port);
-  GR_LOG_INFO(logger, "Apache Thrift: " + endpoint);
-
   d_server = handler.get();
 }
 
@@ -173,27 +169,24 @@ thrift_server_template<TserverBase, 
TserverClass,TImplClass, TThriftClass>::~thr
 template<typename TserverBase, typename TserverClass, typename TImplClass, 
typename TThriftClass>
 TserverBase* thrift_server_template<TserverBase, TserverClass, TImplClass, 
TThriftClass>::i_impl()
 {
-  std::cerr << "thrift_server_template: i_impl" << std::endl;
-
-//     char hostname[1024];
-//     hostname[1023] = '\0';
-//     ::gethostname(hostname, 1023);
-//     ::printf("Hostname: %s\n", hostname);
-//     struct hostent* h;
-//     h = ::gethostbyname(hostname);
-//     ::printf("h_name: %s\n", h->h_name);
+  //std::cerr << "thrift_server_template: i_impl" << std::endl;
 
-       const std::string boost_hostname(boost::asio::ip::host_name());
-       //std::cout << "boost hostname: " << boost_hostname << 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("%1% -p %2%") % 
boost_hostname % used_port);
-  std::cout << "Thrift endpoint: " << endpoint << " boost hostname: " << 
boost_hostname << std::endl;
+  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;
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]