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

Proposed by Thomas Voß
Status: Merged
Approved by: Loïc Minier
Approved revision: 165
Merged at revision: 164
Proposed branch: lp:~thomas-voss/location-service/fix-1414591
Merge into: lp:location-service/trunk
Diff against target: 78 lines (+19/-2)
4 files modified
src/location_service/com/ubuntu/location/providers/remote/provider.cpp (+11/-0)
src/location_service/com/ubuntu/location/providers/remote/provider.h (+3/-0)
src/location_service/com/ubuntu/location/service/daemon.cpp (+1/-2)
src/location_service/com/ubuntu/location/service/runtime_tests.cpp (+4/-0)
To merge this branch: bzr merge lp:~thomas-voss/location-service/fix-1414591
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Loïc Minier Approve
Charles Kerr (community) Approve
Review via email: mp+247640@code.launchpad.net

Commit message

Make the remote::Provider::Stub fail loudly on construction if the other side is not reachable.
Relax the exception in location::Daemon::main and do not exit if instantiating a provider fails.

Description of the change

Make the remote::Provider::Stub fail loudly on construction if the other side is not reachable.
Relax the exception in location::Daemon::main and do not exit if instantiating a provider fails.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

If we wanted to differentiate ping() errors from other errors we could use system_error with a category/code. However it's probably better like this to just log runtime errors instead of bringing the whole service down.

Looks straightforward to me.

review: Approve
Revision history for this message
Loïc Minier (lool) wrote :

LGTM, not tested though

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
166. By Thomas Voß

Add compile guards around runtime tests.

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/remote/provider.cpp'
2--- src/location_service/com/ubuntu/location/providers/remote/provider.cpp 2015-01-25 12:44:20 +0000
3+++ src/location_service/com/ubuntu/location/providers/remote/provider.cpp 2015-01-26 20:15:51 +0000
4@@ -196,6 +196,11 @@
5 cul::Provider::Ptr remote::Provider::Stub::create_instance_with_config(const remote::stub::Configuration& config)
6 {
7 std::shared_ptr<remote::Provider::Stub> result{new remote::Provider::Stub{config}};
8+
9+ // This call throws if we fail to reach the remote end. With that, we make sure that
10+ // we do not return a potentially invalid instance that throws later on.
11+ result->ping();
12+
13 result->setup_event_connections();
14 return result;
15 }
16@@ -256,6 +261,12 @@
17 });
18 }
19
20+void remote::Provider::Stub::ping()
21+{
22+ // Requires reaches out to the remote side and throws in case of issues.
23+ requires(Provider::Requirements::satellites);
24+}
25+
26 remote::Provider::Stub::~Stub() noexcept
27 {
28 VLOG(10) << __PRETTY_FUNCTION__;
29
30=== modified file 'src/location_service/com/ubuntu/location/providers/remote/provider.h'
31--- src/location_service/com/ubuntu/location/providers/remote/provider.h 2015-01-21 20:04:56 +0000
32+++ src/location_service/com/ubuntu/location/providers/remote/provider.h 2015-01-26 20:15:51 +0000
33@@ -83,6 +83,9 @@
34
35 // Yeah, two stage init is evil.
36 void setup_event_connections();
37+ // ping tries to reach out to the remote end and throws
38+ // if the ping fails.
39+ void ping();
40
41 struct Private;
42 std::shared_ptr<Private> d;
43
44=== modified file 'src/location_service/com/ubuntu/location/service/daemon.cpp'
45--- src/location_service/com/ubuntu/location/service/daemon.cpp 2015-01-25 12:45:30 +0000
46+++ src/location_service/com/ubuntu/location/service/daemon.cpp 2015-01-26 20:15:51 +0000
47@@ -195,8 +195,7 @@
48
49 } catch(const std::runtime_error& e)
50 {
51- std::cerr << "Exception instantiating provider: " << e.what() << " ... Aborting now." << std::endl;
52- return EXIT_FAILURE;
53+ std::cerr << "Issue instantiating provider: " << e.what() << std::endl;
54 }
55 }
56
57
58=== modified file 'src/location_service/com/ubuntu/location/service/runtime_tests.cpp'
59--- src/location_service/com/ubuntu/location/service/runtime_tests.cpp 2015-01-13 13:00:24 +0000
60+++ src/location_service/com/ubuntu/location/service/runtime_tests.cpp 2015-01-26 20:15:51 +0000
61@@ -70,6 +70,7 @@
62 }
63 };
64
65+#if defined(COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_GPS)
66 int snr_and_ttff()
67 {
68 typedef boost::accumulators::accumulator_set<
69@@ -170,6 +171,9 @@
70
71 return 0;
72 }
73+#else
74+int snr_and_ttff() { return 0; }
75+#endif // COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_GPS
76 }
77
78 int location::service::execute_runtime_tests()

Subscribers

People subscribed via source and target branches