Merge lp:~thomas-voss/location-service/fix-1240878 into lp:location-service/trunk

Proposed by Thomas Voß
Status: Merged
Approved by: Thomas Voß
Approved revision: 49
Merged at revision: 49
Proposed branch: lp:~thomas-voss/location-service/fix-1240878
Merge into: lp:location-service/trunk
Diff against target: 60 lines (+28/-11)
2 files modified
src/location_service/com/ubuntu/location/providers/gps/provider.cpp (+13/-0)
src/location_service/com/ubuntu/location/service/skeleton.cpp (+15/-11)
To merge this branch: bzr merge lp:~thomas-voss/location-service/fix-1240878
Reviewer Review Type Date Requested Status
Olivier Tilloy Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+191593@code.launchpad.net

Commit message

 * Fix a race when a session is created while another one ends.
 * Ensure a sensible minimum interval between consecutive location updates in the GPS provider.

Description of the change

 * Fix a race when a session is created while another one ends.
 * Ensure a sensible minimum interval between consecutive location updates in the GPS provider.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Those changes are apparently not enough to fix bug #1240878.
However from a quick scan of the diff they look reasonable, so I’m fine with them if you think they can improve the general situation.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/location_service/com/ubuntu/location/providers/gps/provider.cpp'
2--- src/location_service/com/ubuntu/location/providers/gps/provider.cpp 2013-08-23 13:50:56 +0000
3+++ src/location_service/com/ubuntu/location/providers/gps/provider.cpp 2013-10-17 10:38:06 +0000
4@@ -183,6 +183,19 @@
5 d->gps_params.context = this;
6
7 d->gps_handle = u_hardware_gps_new(std::addressof(d->gps_params));
8+
9+ static const std::chrono::milliseconds minimum_interval{500};
10+ static const uint32_t preferred_accuracy{0};
11+ static const uint32_t preferred_time_to_first_fix{0};
12+
13+ u_hardware_gps_set_position_mode(
14+ d->gps_handle,
15+ U_HARDWARE_GPS_POSITION_MODE_MS_BASED,
16+ U_HARDWARE_GPS_POSITION_RECURRENCE_PERIODIC,
17+ minimum_interval.count(),
18+ preferred_accuracy,
19+ preferred_time_to_first_fix
20+ );
21 }
22
23 culg::Provider::~Provider() noexcept
24
25=== modified file 'src/location_service/com/ubuntu/location/service/skeleton.cpp'
26--- src/location_service/com/ubuntu/location/service/skeleton.cpp 2013-06-10 11:10:00 +0000
27+++ src/location_service/com/ubuntu/location/service/skeleton.cpp 2013-10-17 10:38:06 +0000
28@@ -198,17 +198,21 @@
29 auto service = dbus::Service::use_service(parent->access_bus(), dbus_message_get_sender(msg));
30 auto object = service->object_for_path(session->path());
31
32- auto wrapper = SessionWrapper::Ptr{new SessionWrapper{shared_from_this(), session, service, object}};
33-
34- auto reply = dbus::Message::make_method_return(msg);
35- reply->writer() << session->path();
36- parent->access_bus()->send(reply->get());
37-
38- bool inserted = false;
39- std::tie(std::ignore, inserted) = session_store.insert(std::make_pair(session->path(), wrapper));
40-
41- if (!inserted)
42- throw std::runtime_error("Could not insert duplicate session into store.");
43+ {
44+ std::lock_guard<std::mutex> lg(guard);
45+
46+ auto wrapper = SessionWrapper::Ptr{new SessionWrapper{shared_from_this(), session, service, object}};
47+
48+ auto reply = dbus::Message::make_method_return(msg);
49+ reply->writer() << session->path();
50+ parent->access_bus()->send(reply->get());
51+
52+ bool inserted = false;
53+ std::tie(std::ignore, inserted) = session_store.insert(std::make_pair(session->path(), wrapper));
54+
55+ if (!inserted)
56+ throw std::runtime_error("Could not insert duplicate session into store.");
57+ }
58
59 } catch(const std::runtime_error& e)
60 {

Subscribers

People subscribed via source and target branches