diff options
author | Nate Goergen <nate.goergen.gitlab1@mile10.com> | 2015-04-16 10:26:49 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2015-04-16 10:26:49 -0400 |
commit | e9d9cf5aced8ed80bc71d817c114866babef3942 (patch) | |
tree | 7ee5da388b8b6d41caf43356cbb1d6a5099acdc8 /gnuradio-runtime/lib/controlport | |
parent | b092142302bcf8c771ec68e61da7781eb406c86f (diff) |
controlport: cleanup and thread safety.
Cleaned up some of the templates for only the necessary stuff.
Adds mutex lock protections around getters and setters.
Diffstat (limited to 'gnuradio-runtime/lib/controlport')
-rw-r--r-- | gnuradio-runtime/lib/controlport/thrift/rpcserver_booter_thrift.cc | 14 | ||||
-rw-r--r-- | gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc | 8 |
2 files changed, 13 insertions, 9 deletions
diff --git a/gnuradio-runtime/lib/controlport/thrift/rpcserver_booter_thrift.cc b/gnuradio-runtime/lib/controlport/thrift/rpcserver_booter_thrift.cc index 40cfe1a48a..1d6cafe0c0 100644 --- a/gnuradio-runtime/lib/controlport/thrift/rpcserver_booter_thrift.cc +++ b/gnuradio-runtime/lib/controlport/thrift/rpcserver_booter_thrift.cc @@ -42,8 +42,7 @@ namespace { rpcserver_booter_thrift::rpcserver_booter_thrift() : thrift_server_template<rpcserver_base, rpcserver_thrift, - rpcserver_booter_thrift, - boost::shared_ptr<GNURadio::ControlPortIf> >(this), + rpcserver_booter_thrift>(this), d_type(std::string(CONTROL_PORT_CLASS)) {;} @@ -54,8 +53,7 @@ rpcserver_base* rpcserver_booter_thrift::i() { return thrift_server_template<rpcserver_base, rpcserver_thrift, - rpcserver_booter_thrift, - GNURadio::ControlPortIf>::i(); + rpcserver_booter_thrift>::i(); } /*! @@ -66,8 +64,7 @@ const std::vector<std::string> rpcserver_booter_thrift::endpoints() { return thrift_server_template<rpcserver_base, rpcserver_thrift, - rpcserver_booter_thrift, - GNURadio::ControlPortIf>::endpoints(); + rpcserver_booter_thrift>::endpoints(); } // Specialized thrift_application_base attributes and functions @@ -87,14 +84,13 @@ const unsigned int thrift_application_base<rpcserver_base, rpcserver_booter_thri ALRIGHT_DEFAULT_BUFFER_SIZE); template<class rpcserver_base, class rpcserver_booter_thrift> -std::auto_ptr<thrift_application_base_impl> +boost::scoped_ptr<thrift_application_base_impl> thrift_application_base<rpcserver_base, rpcserver_booter_thrift>::p_impl( new thrift_application_base_impl()); template<class rpcserver_base, class rpcserver_booter_thrift> thrift_application_base<rpcserver_base, rpcserver_booter_thrift>::~thrift_application_base() { - GR_LOG_DEBUG(d_debug_logger, "thrift_application_base: shutdown"); if(d_thirft_is_running) { d_thriftserver->stop(); d_thirft_is_running = false; @@ -125,7 +121,7 @@ bool thrift_application_base<rpcserver_base, rpcserver_booter_thrift>::applicati 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(d_logger, "Apache Thrift: " + endpoint); diff --git a/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc b/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc index c4655d366e..3e6eabc854 100644 --- a/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc +++ b/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc @@ -49,6 +49,7 @@ void rpcserver_thrift::registerConfigureCallback(const std::string &id, const configureCallback_t callback) { + boost::mutex::scoped_lock lock(d_callback_map_lock); { ConfigureCallbackMap_t::const_iterator iter(d_setcallbackmap.find(id)); if(iter != d_setcallbackmap.end()) { @@ -68,6 +69,7 @@ rpcserver_thrift::registerConfigureCallback(const std::string &id, void rpcserver_thrift::unregisterConfigureCallback(const std::string &id) { + boost::mutex::scoped_lock lock(d_callback_map_lock); ConfigureCallbackMap_t::iterator iter(d_setcallbackmap.find(id)); if(iter == d_setcallbackmap.end()) { std::stringstream s; @@ -86,6 +88,7 @@ void rpcserver_thrift::registerQueryCallback(const std::string &id, const queryCallback_t callback) { + boost::mutex::scoped_lock lock(d_callback_map_lock); { QueryCallbackMap_t::const_iterator iter(d_getcallbackmap.find(id)); if(iter != d_getcallbackmap.end()) { @@ -105,6 +108,7 @@ rpcserver_thrift::registerQueryCallback(const std::string &id, void rpcserver_thrift::unregisterQueryCallback(const std::string &id) { + boost::mutex::scoped_lock lock(d_callback_map_lock); QueryCallbackMap_t::iterator iter(d_getcallbackmap.find(id)); if(iter == d_getcallbackmap.end()) { std::stringstream s; @@ -123,6 +127,7 @@ rpcserver_thrift::unregisterQueryCallback(const std::string &id) void rpcserver_thrift::setKnobs(const GNURadio::KnobMap& knobs) { + boost::mutex::scoped_lock lock(d_callback_map_lock); std::for_each(knobs.begin(), knobs.end(), set_f<GNURadio::KnobMap::value_type,ConfigureCallbackMap_t> (d_setcallbackmap, cur_priv)); @@ -133,6 +138,7 @@ void rpcserver_thrift::getKnobs(GNURadio::KnobMap& _return, const GNURadio::KnobIDList& knobs) { + boost::mutex::scoped_lock lock(d_callback_map_lock); if(knobs.size() == 0) { std::for_each(d_getcallbackmap.begin(), d_getcallbackmap.end(), get_all_f<QueryCallbackMap_t::value_type, QueryCallbackMap_t, GNURadio::KnobMap> @@ -148,6 +154,7 @@ rpcserver_thrift::getKnobs(GNURadio::KnobMap& _return, void rpcserver_thrift::getRe(GNURadio::KnobMap& _return, const GNURadio::KnobIDList& knobs) { + boost::mutex::scoped_lock lock(d_callback_map_lock); if(knobs.size() == 0) { std::for_each(d_getcallbackmap.begin(), d_getcallbackmap.end(), get_all_f<QueryCallbackMap_t::value_type, QueryCallbackMap_t, GNURadio::KnobMap> @@ -172,6 +179,7 @@ void rpcserver_thrift::properties(GNURadio::KnobPropMap& _return, const GNURadio::KnobIDList& knobs) { + boost::mutex::scoped_lock lock(d_callback_map_lock); if(knobs.size() == 0) { std::for_each(d_getcallbackmap.begin(), d_getcallbackmap.end(), properties_all_f<QueryCallbackMap_t::value_type, |