Skip to content

Commit a5e49d9

Browse files
maitbotmarcusmueller
authored andcommittedDec 19, 2020
RPC fixes to allow using Thrift-0.13
Adds ability for master to build with newer Thrift versions by checking availability of thrift include files. (Also spelling fix: Thift -> Thrift) And fix up logging for rpcserver_thrift class.
1 parent 7e112bf commit a5e49d9

File tree

5 files changed

+46
-14
lines changed

5 files changed

+46
-14
lines changed
 

‎cmake/Modules/FindTHRIFT.cmake

+13-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,19 @@ ENDIF (CMAKE_CROSSCOMPILING)
7272

7373
# Set to found if we've made it this far
7474
if(THRIFT_INCLUDE_DIRS AND THRIFT_LIBRARIES AND PYTHON_THRIFT_FOUND)
75-
set(THRIFT_FOUND TRUE CACHE BOOL "If Thift has been found")
75+
set(THRIFT_FOUND TRUE CACHE BOOL "If Thrift has been found")
76+
77+
find_file(THRIFT_HAS_VERSION_H thrift/version.h
78+
PATH ${THRIFT_INCLUDE_DIRS} NO_DEFAULT_PATH)
79+
if(THRIFT_HAS_VERSION_H-FOUND)
80+
set(THRIFT_HAS_VERSION_H TRUE CACHE BOOL "If Thrift has thrift/version.h")
81+
endif()
82+
83+
find_file(THRIFT_HAS_THREADFACTORY_H thrift/concurrency/ThreadFactory.h
84+
PATH ${THRIFT_INCLUDE_DIRS} NO_DEFAULT_PATH)
85+
if(THRIFT_HAS_THREADFACTORY_H-FOUND)
86+
set(THRIFT_HAS_THREADFACTORY_H TRUE CACHE BOOL "If Thrift has thrift/concurrency/ThreadFactory.h")
87+
endif()
7688
endif(THRIFT_INCLUDE_DIRS AND THRIFT_LIBRARIES AND PYTHON_THRIFT_FOUND)
7789

7890

‎config.h.in

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
#ifndef GR_RPCSERVER_THRIFT
2525
#cmakedefine GR_RPCSERVER_THRIFT
2626
#endif
27+
#ifndef THRIFT_HAS_VERSION_H
28+
#cmakedefine THRIFT_HAS_VERSION_H
29+
#endif
30+
#ifndef THRIFT_HAS_THREADFACTORY_H
31+
#cmakedefine THRIFT_HAS_THREADFACTORY_H
32+
#endif
2733
#ifndef GR_MPLIB_GMP
2834
#cmakedefine GR_MPLIB_GMP
2935
#endif

‎gnuradio-runtime/include/gnuradio/rpcserver_thrift.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
class rpcserver_thrift : public virtual rpcserver_base, public GNURadio::ControlPortIf
3131
{
3232
public:
33-
gr::logger_ptr d_logger;
34-
gr::logger_ptr d_debug_logger;
35-
3633
rpcserver_thrift();
3734
virtual ~rpcserver_thrift();
3835

@@ -82,6 +79,9 @@ class rpcserver_thrift : public virtual rpcserver_base, public GNURadio::Control
8279
virtual void shutdown();
8380

8481
private:
82+
static gr::logger_ptr d_logger;
83+
static gr::logger_ptr d_debug_logger;
84+
8585
boost::mutex d_callback_map_lock;
8686

8787
typedef std::map<std::string, configureCallback_t> ConfigureCallbackMap_t;
@@ -108,7 +108,7 @@ class rpcserver_thrift : public virtual rpcserver_base, public GNURadio::Control
108108
msg << _handlerCallback.description
109109
<< " requires PRIVLVL <= " << _handlerCallback.priv
110110
<< " to set, currently at: " << cur_priv;
111-
GR_LOG_ERROR(logger, msg.str());
111+
GR_LOG_ERROR(d_logger, msg.str());
112112
}
113113
}
114114

@@ -133,7 +133,7 @@ class rpcserver_thrift : public virtual rpcserver_base, public GNURadio::Control
133133
msg << "Key " << p.first
134134
<< " requires PRIVLVL <= " << iter->second.priv
135135
<< " to set, currently at: " << cur_priv;
136-
GR_LOG_ERROR(logger, msg.str());
136+
GR_LOG_ERROR(d_logger, msg.str());
137137
}
138138
} else {
139139
throw apache::thrift::TApplicationException(__FILE__ " " S__LINE__);
@@ -165,12 +165,12 @@ class rpcserver_thrift : public virtual rpcserver_base, public GNURadio::Control
165165
msg << "Key " << iter->first
166166
<< " requires PRIVLVL: <= " << iter->second.priv
167167
<< " to get, currently at: " << cur_priv;
168-
GR_LOG_ERROR(logger, msg.str());
168+
GR_LOG_ERROR(d_logger, msg.str());
169169
}
170170
} else {
171171
std::ostringstream smsgs;
172-
msg << "Ctrlport Key called with unregistered key (" << p << ")\n";
173-
GR_LOG_ERROR(logger, ss.str());
172+
smsgs << "Ctrlport Key called with unregistered key (" << p << ")\n";
173+
GR_LOG_ERROR(d_logger, smsgs.str());
174174
throw apache::thrift::TApplicationException(__FILE__ " " S__LINE__);
175175
}
176176
}
@@ -197,7 +197,7 @@ class rpcserver_thrift : public virtual rpcserver_base, public GNURadio::Control
197197
std::ostringstream msg;
198198
msg << "Key " << p.first << " requires PRIVLVL: <= " << p.second.priv
199199
<< " to get, currently at: " << cur_priv;
200-
GR_LOG_ERROR(logger, msg.str());
200+
GR_LOG_ERROR(d_logger, msg.str());
201201
}
202202
}
203203

@@ -231,7 +231,7 @@ class rpcserver_thrift : public virtual rpcserver_base, public GNURadio::Control
231231
std::ostringstream msg;
232232
msg << "Key " << p.first << " requires PRIVLVL: <= " << p.second.priv
233233
<< " to get, currently at: " << cur_priv;
234-
GR_LOG_ERROR(logger, msg.str());
234+
GR_LOG_ERROR(d_logger, msg.str());
235235
}
236236
}
237237

@@ -268,7 +268,7 @@ class rpcserver_thrift : public virtual rpcserver_base, public GNURadio::Control
268268
msg << "Key " << iter->first
269269
<< " requires PRIVLVL: <= " << iter->second.priv
270270
<< " to get, currently at: " << cur_priv;
271-
GR_LOG_ERROR(logger, msg.str());
271+
GR_LOG_ERROR(d_logger, msg.str());
272272
}
273273
} else {
274274
throw apache::thrift::TApplicationException(__FILE__ " " S__LINE__);

‎gnuradio-runtime/include/gnuradio/thrift_server_template.h

+10
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@
1111
#ifndef THRIFT_SERVER_TEMPLATE_H
1212
#define THRIFT_SERVER_TEMPLATE_H
1313

14+
#include <gnuradio/config.h>
1415
#include <gnuradio/logger.h>
1516
#include <gnuradio/prefs.h>
1617
#include <gnuradio/thrift_application_base.h>
1718
#include <iostream>
1819

1920
#include "thrift/ControlPort.h"
21+
#ifdef THRIFT_HAS_THREADFACTORY_H
22+
#include <thrift/concurrency/ThreadFactory.h>
23+
#else
2024
#include <thrift/concurrency/PlatformThreadFactory.h>
25+
#endif
2126
#include <thrift/concurrency/ThreadManager.h>
2227
#include <thrift/server/TSimpleServer.h>
2328
#include <thrift/server/TThreadPoolServer.h>
@@ -124,9 +129,14 @@ thrift_server_template<TserverBase, TserverClass, TImplClass>::thrift_server_tem
124129
std::shared_ptr<thrift::concurrency::ThreadManager> threadManager(
125130
thrift::concurrency::ThreadManager::newSimpleThreadManager(nthreads));
126131

132+
#ifdef THRIFT_HAS_THREADFACTORY_H
133+
threadManager->threadFactory(std::shared_ptr<thrift::concurrency::ThreadFactory>(
134+
new thrift::concurrency::ThreadFactory()));
135+
#else
127136
threadManager->threadFactory(
128137
std::shared_ptr<thrift::concurrency::PlatformThreadFactory>(
129138
new thrift::concurrency::PlatformThreadFactory()));
139+
#endif
130140

131141
threadManager->start();
132142

‎gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@
2323

2424
using namespace rpcpmtconverter;
2525

26+
gr::logger_ptr rpcserver_thrift::d_logger;
27+
gr::logger_ptr rpcserver_thrift::d_debug_logger;
28+
29+
2630
rpcserver_thrift::rpcserver_thrift()
2731
{
28-
gr::configure_default_loggers(logger, debug_logger, "rpcserver_thrift");
32+
gr::configure_default_loggers(d_logger, d_debug_logger, "rpcserver_thrift");
2933
// std::cerr << "rpcserver_thrift::ctor" ;
3034
}
3135

@@ -273,7 +277,7 @@ void rpcserver_thrift::shutdown()
273277
{
274278
if (DEBUG) {
275279
std::ostringstream msg;
276-
msg << "shutting down... " << id;
280+
msg << "shutting down rpcserver_thrift... ";
277281
GR_LOG_INFO(d_debug_logger, msg.str());
278282
}
279283
}

0 commit comments

Comments
 (0)
Please sign in to comment.