Merge lp:~jpakkane/indicator-network/moregrace into lp:indicator-network/14.10

Proposed by Jussi Pakkanen
Status: Merged
Approved by: Antti Kaijanmäki
Approved revision: 418
Merged at revision: 417
Proposed branch: lp:~jpakkane/indicator-network/moregrace
Merge into: lp:indicator-network/14.10
Diff against target: 138 lines (+53/-35)
3 files modified
src/connectivity-cpp/src/platform/nmofono/manager.cpp (+9/-1)
src/connectivity-cpp/src/platform/nmofono/wifi/link.cpp (+33/-33)
src/indicator/modem-manager.cpp (+11/-1)
To merge this branch: bzr merge lp:~jpakkane/indicator-network/moregrace
Reviewer Review Type Date Requested Status
Antti Kaijanmäki (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+232543@code.launchpad.net

Commit message

A few more graceful exits.

Description of the change

A few more graceful exits.

To post a comment you must log in.
418. By Jussi Pakkanen

Comment fixing.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

LGTM.

review: Approve
419. By Jussi Pakkanen

Expand scope of try/catch block.

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Now with an even larger try/catch block.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/connectivity-cpp/src/platform/nmofono/manager.cpp'
2--- src/connectivity-cpp/src/platform/nmofono/manager.cpp 2014-08-19 19:55:15 +0000
3+++ src/connectivity-cpp/src/platform/nmofono/manager.cpp 2014-08-29 06:56:29 +0000
4@@ -72,7 +72,15 @@
5 m_bus->install_executor(executor);
6 worker = std::move(std::thread([this]()
7 {
8- m_bus->run();
9+ try {
10+ m_bus->run();
11+ } catch(std::exception &e) {
12+ /// @bug dbus-cpp internal logic exploded
13+ // If this happens, indicator-network is in an unknown state with no clear way of
14+ // recovering. The only reasonable way out is a graceful exit.
15+ std::cerr << __PRETTY_FUNCTION__ << " Failed to run dbus service: " << e.what() << std::endl;
16+ exit(0);
17+ }
18 }));
19 location::set_name_for_thread(
20 worker,
21
22=== modified file 'src/connectivity-cpp/src/platform/nmofono/wifi/link.cpp'
23--- src/connectivity-cpp/src/platform/nmofono/wifi/link.cpp 2014-08-26 13:20:49 +0000
24+++ src/connectivity-cpp/src/platform/nmofono/wifi/link.cpp 2014-08-29 06:56:29 +0000
25@@ -324,42 +324,42 @@
26 void
27 Link::connect_to(std::shared_ptr<networking::wifi::AccessPoint> accessPoint)
28 {
29- p->connecting = true;
30- std::vector<int8_t> ssid;
31- std::shared_ptr<GroupedAccessPoint> ap = std::dynamic_pointer_cast<GroupedAccessPoint>(accessPoint);
32- // The accesspoint interface does not provide this property so we need to coax it out of
33- // derived classes.
34- if(ap) {
35- ssid = ap->get_ap().ssid->get();
36- } else {
37- std::shared_ptr<AccessPoint> bap = std::dynamic_pointer_cast<AccessPoint>(accessPoint);
38- assert(bap);
39- ssid = bap->get_ap().ssid->get();
40- }
41- NM::Interface::Connection *found = nullptr;
42- auto connections = p->dev.get_available_connections();
43- for (auto &con : connections) {
44- for (auto map : con.get_settings()) {
45- if (map.first == "802-11-wireless") {
46- for (auto conf : map.second) {
47- if (conf.first == "ssid") {
48- std::vector<int8_t> value;
49- value = conf.second.as<std::vector<std::int8_t>>();
50- if (value == ap->get_ap().ssid->get()) {
51- found = &con;
52- break;
53+ try {
54+ p->connecting = true;
55+ std::vector<int8_t> ssid;
56+ std::shared_ptr<GroupedAccessPoint> ap = std::dynamic_pointer_cast<GroupedAccessPoint>(accessPoint);
57+ // The accesspoint interface does not provide this property so we need to coax it out of
58+ // derived classes.
59+ if(ap) {
60+ ssid = ap->get_ap().ssid->get();
61+ } else {
62+ std::shared_ptr<AccessPoint> bap = std::dynamic_pointer_cast<AccessPoint>(accessPoint);
63+ assert(bap);
64+ ssid = bap->get_ap().ssid->get();
65+ }
66+ NM::Interface::Connection *found = nullptr;
67+ auto connections = p->dev.get_available_connections();
68+ for (auto &con : connections) {
69+ for (auto map : con.get_settings()) {
70+ if (map.first == "802-11-wireless") {
71+ for (auto conf : map.second) {
72+ if (conf.first == "ssid") {
73+ std::vector<int8_t> value;
74+ value = conf.second.as<std::vector<std::int8_t>>();
75+ if (value == ap->get_ap().ssid->get()) {
76+ found = &con;
77+ break;
78+ }
79 }
80 }
81 }
82 }
83 }
84- }
85-
86- /// @todo check the timestamps as there might be multiple ones that are suitable.
87- /// @todo oh, and check more parameters than just the ssid
88-
89- core::dbus::types::ObjectPath ac;
90- try {
91+
92+ /// @todo check the timestamps as there might be multiple ones that are suitable.
93+ /// @todo oh, and check more parameters than just the ssid
94+
95+ core::dbus::types::ObjectPath ac;
96 if (found) {
97 ac = p->nm.activate_connection(found->object->path(),
98 p->dev.object->path(),
99@@ -378,6 +378,8 @@
100 ap->object_path());
101 ac = std::get<1>(ret);
102 }
103+ updateActiveConnection(ac);
104+ p->connecting = false;
105 } catch(const std::exception &e) {
106 // @bug default timeout expired: LP(#1361642)
107 // If this happens, indicator-network is in an unknown state with no clear way of
108@@ -385,8 +387,6 @@
109 std::cerr << __PRETTY_FUNCTION__ << " Failed to activate connection: " << e.what() << std::endl;
110 exit(0);
111 }
112- updateActiveConnection(ac);
113- p->connecting = false;
114 }
115
116 const Property<std::shared_ptr<networking::wifi::AccessPoint> >&
117
118=== modified file 'src/indicator/modem-manager.cpp'
119--- src/indicator/modem-manager.cpp 2014-08-07 21:14:42 +0000
120+++ src/indicator/modem-manager.cpp 2014-08-29 06:56:29 +0000
121@@ -52,7 +52,17 @@
122
123 auto executor = core::dbus::asio::make_executor(m_bus);
124 m_bus->install_executor(executor);
125- m_ofonoWorker = std::move(std::thread([this](){ m_bus->run(); }));
126+ m_ofonoWorker = std::move(std::thread([this](){
127+ try {
128+ m_bus->run();
129+ } catch(std::exception &e) {
130+ /// @bug dbus-cpp internal logic exploded
131+ // If this happens, indicator-network is in an unknown state with no clear way of
132+ // recovering. The only reasonable way out is a graceful exit.
133+ std::cerr << __PRETTY_FUNCTION__ << " Failed to run dbus service: " << e.what() << std::endl;
134+ exit(0);
135+ }
136+ }));
137
138 m_dbus.reset(new core::dbus::DBus(m_bus));
139

Subscribers

People subscribed via source and target branches