Merge lp:~thomas-voss/location-service/fix-match-rule-leak into lp:location-service/15.04

Proposed by Thomas Voß
Status: Merged
Approved by: Alberto Mardegan
Approved revision: 204
Merged at revision: 207
Proposed branch: lp:~thomas-voss/location-service/fix-match-rule-leak
Merge into: lp:location-service/15.04
Diff against target: 117 lines (+35/-11)
4 files modified
src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp (+12/-6)
src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h (+12/-0)
src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp (+1/-1)
src/location_service/com/ubuntu/location/service/provider_daemon.cpp (+10/-4)
To merge this branch: bzr merge lp:~thomas-voss/location-service/fix-match-rule-leak
Reviewer Review Type Date Requested Status
Alberto Mardegan (community) Approve
Review via email: mp+277179@code.launchpad.net

Commit message

Ensure that event connections are cleaned up on destruction.

Description of the change

Ensure that event connections are cleaned up on destruction.

To post a comment you must log in.
199. By Thomas Voß

Instrument on_access_point_{added, removed} with log messages.

200. By Thomas Voß

One connection is more than enough.

201. By Thomas Voß

Don't add, just use an existing object.

202. By Thomas Voß

Log destruction of CachedWirelessNetwork instances.

203. By Thomas Voß

Remove temporary log output.

204. By Thomas Voß

Revert accidental change to debian/source/format.

Revision history for this message
Alberto Mardegan (mardy) wrote :

The last chunk of changes looks unrelated and it's not obvious whether what it's solving. But if that's not an accidental change, it all looks good to me.

review: Approve
205. By Thomas Voß

[ Alberto Mardegan ]
* Send last known position on session start
[ CI Train Bot ]
* New rebuild forced.
[ Thomas Voß ]
* Factor out service::Runtime from daemon.cpp into its own .h/.cpp
  pair of files. Add test cases around correct operation of
  service::Runtime. added:
  src/location_service/com/ubuntu/location/service/runtime.cpp
  src/location_service/com/ubuntu/location/service/runtime.h
  tests/runtime_test.cpp
[ thomas-voss ]
* Factor out service::Runtime from daemon.cpp into its own .h/.cpp
  pair of files. Add test cases around correct operation of
  service::Runtime. added:
  src/location_service/com/ubuntu/location/service/runtime.cpp
  src/location_service/com/ubuntu/location/service/runtime.h
  tests/runtime_test.cpp
* Adjust default timeout for downloading GPS XTRA data.
[ Alberto Mardegan ]
* Make sure that injected time is given in milliseconds
[ Thomas Voß ]
* Cherry-pick rev. 196 and 199 from lp:location-service. The changes
  got accidentally removed by merging the outstanding documentation
  branch.
* Handle responses of clients to updates asynchronously. Rely on
  dummy::ConnectivityManager as harvesting is disabled anyway. (LP:
  #1462664, #1387643)

206. By Thomas Voß

Revert accidental changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp'
--- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2015-05-28 10:57:24 +0000
+++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2015-12-02 12:11:29 +0000
@@ -123,7 +123,14 @@
123 const org::freedesktop::NetworkManager::Device& device,123 const org::freedesktop::NetworkManager::Device& device,
124 const org::freedesktop::NetworkManager::AccessPoint& ap)124 const org::freedesktop::NetworkManager::AccessPoint& ap)
125 : device_(device),125 : device_(device),
126 access_point_(ap)126 access_point_(ap),
127 connections
128 {
129 access_point_.properties_changed->connect([this](const std::map<std::string, core::dbus::types::Variant>& dict)
130 {
131 on_access_point_properties_changed(dict);
132 })
133 }
127{134{
128 last_seen_ = translate_time_stamp(access_point_.last_seen->get());135 last_seen_ = translate_time_stamp(access_point_.last_seen->get());
129136
@@ -138,12 +145,11 @@
138 {145 {
139 static_cast<int>(access_point_.strength->get())146 static_cast<int>(access_point_.strength->get())
140 };147 };
148}
141149
142 // Wire up all the connections150detail::CachedWirelessNetwork::~CachedWirelessNetwork()
143 access_point_.properties_changed->connect([this](const std::map<std::string, core::dbus::types::Variant>& dict)151{
144 {152 access_point_.properties_changed->disconnect(connections.ap_properties_changed);
145 on_access_point_properties_changed(dict);
146 });
147}153}
148154
149void detail::CachedWirelessNetwork::on_access_point_properties_changed(const std::map<std::string, core::dbus::types::Variant>& dict)155void detail::CachedWirelessNetwork::on_access_point_properties_changed(const std::map<std::string, core::dbus::types::Variant>& dict)
150156
=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h'
--- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h 2014-08-14 20:25:22 +0000
+++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h 2015-12-02 12:11:29 +0000
@@ -41,6 +41,8 @@
41 const org::freedesktop::NetworkManager::Device& device,41 const org::freedesktop::NetworkManager::Device& device,
42 const org::freedesktop::NetworkManager::AccessPoint& ap);42 const org::freedesktop::NetworkManager::AccessPoint& ap);
4343
44 ~CachedWirelessNetwork();
45
44 // Timestamp when the network became visible.46 // Timestamp when the network became visible.
45 const core::Property<std::chrono::system_clock::time_point>& last_seen() const override;47 const core::Property<std::chrono::system_clock::time_point>& last_seen() const override;
4648
@@ -67,6 +69,16 @@
67 // The actual access point stub.69 // The actual access point stub.
68 org::freedesktop::NetworkManager::AccessPoint access_point_;70 org::freedesktop::NetworkManager::AccessPoint access_point_;
6971
72 // Encapsulates all event connections that have to be cut on destruction.
73 struct
74 {
75 core::dbus::Signal
76 <
77 org::freedesktop::NetworkManager::AccessPoint::PropertiesChanged,
78 org::freedesktop::NetworkManager::AccessPoint::PropertiesChanged::ArgumentType
79 >::SubscriptionToken ap_properties_changed;
80 } connections;
81
70 core::Property<std::chrono::system_clock::time_point> last_seen_;82 core::Property<std::chrono::system_clock::time_point> last_seen_;
71 core::Property<std::string> bssid_;83 core::Property<std::string> bssid_;
72 core::Property<std::string> ssid_;84 core::Property<std::string> ssid_;
7385
=== modified file 'src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp'
--- src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-05-27 18:40:37 +0000
+++ src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-12-02 12:11:29 +0000
@@ -595,7 +595,7 @@
595595
596 xdg::NetworkManager::AccessPoint ap596 xdg::NetworkManager::AccessPoint ap
597 {597 {
598 network_manager->service->add_object_for_path(ap_path)598 network_manager->service->object_for_path(ap_path)
599 };599 };
600600
601 auto wifi = std::make_shared<detail::CachedWirelessNetwork>(itd->second, ap);601 auto wifi = std::make_shared<detail::CachedWirelessNetwork>(itd->second, ap);
602602
=== modified file 'src/location_service/com/ubuntu/location/service/provider_daemon.cpp'
--- src/location_service/com/ubuntu/location/service/provider_daemon.cpp 2015-11-25 09:20:12 +0000
+++ src/location_service/com/ubuntu/location/service/provider_daemon.cpp 2015-12-02 12:11:29 +0000
@@ -108,6 +108,14 @@
108 return result;108 return result;
109}109}
110110
111namespace
112{
113std::shared_ptr<location::service::Runtime> runtime()
114{
115 static const auto inst = location::service::Runtime::create(1);
116 return inst;
117}
118}
111int location::service::ProviderDaemon::main(const location::service::ProviderDaemon::Configuration& config)119int location::service::ProviderDaemon::main(const location::service::ProviderDaemon::Configuration& config)
112{120{
113 auto trap = core::posix::trap_signals_for_all_subsequent_threads(121 auto trap = core::posix::trap_signals_for_all_subsequent_threads(
@@ -121,9 +129,7 @@
121 trap->stop();129 trap->stop();
122 });130 });
123131
124 auto runtime = location::service::Runtime::create(1);132 config.connection->install_executor(core::dbus::asio::make_executor(config.connection, runtime()->service()));
125
126 config.connection->install_executor(core::dbus::asio::make_executor(config.connection, runtime->service()));
127133
128 auto skeleton = location::providers::remote::skeleton::create_with_configuration(location::providers::remote::skeleton::Configuration134 auto skeleton = location::providers::remote::skeleton::create_with_configuration(location::providers::remote::skeleton::Configuration
129 {135 {
@@ -132,7 +138,7 @@
132 config.provider138 config.provider
133 });139 });
134140
135 runtime->start();141 runtime()->start();
136142
137 trap->run();143 trap->run();
138144

Subscribers

People subscribed via source and target branches