Mir

Merge lp:~alan-griffiths/mir/simplify-connect-code into lp:mir

Proposed by Alan Griffiths on 2015-08-21
Status: Merged
Approved by: Alexandros Frantzis on 2015-08-25
Approved revision: 2869
Merged at revision: 2876
Proposed branch: lp:~alan-griffiths/mir/simplify-connect-code
Merge into: lp:mir
Diff against target: 34 lines (+2/-11)
1 file modified
src/client/mir_connection.cpp (+2/-11)
To merge this branch: bzr merge lp:~alan-griffiths/mir/simplify-connect-code
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-08-25
Kevin DuBois (community) Approve on 2015-08-24
Daniel van Vugt Abstain on 2015-08-24
Chris Halse Rogers Approve on 2015-08-24
Cemil Azizoglu (community) 2015-08-21 Approve on 2015-08-21
Review via email: mp+268740@code.launchpad.net

Commit Message

client: remove a path that could no longer execute

Description of the Change

client: remove a path that could no longer execute.

"connect_result->has_error()" is always true as connect_result->error() is set in the constructor.

Further, connect errors always result in the server disconnecting without replying, so we never get an error in the result object.

All of this means the error message is misleading and the logic overly complex.

To post a comment you must log in.
Cemil Azizoglu (cemil-azizoglu) wrote :

ok

Cemil Azizoglu (cemil-azizoglu) wrote :

oops

review: Approve
Chris Halse Rogers (raof) wrote :

Yup, correct.

review: Approve
Daniel van Vugt (vanvugt) wrote :

It seems like connect_done=true and set_error_message("Connect failed") should be mutually exclusive things. Because if the connect failed it's arguably never done. Unless done means "attempted". Needs checking...

review: Needs Information
Daniel van Vugt (vanvugt) wrote :

Unrelated failures. I sense these are going to pop up elsewhere too...

[ FAILED ] ExchangeBufferTest.server_can_send_buffer
[ FAILED ] FD leak was detected

Daniel van Vugt (vanvugt) wrote :
Chris Halse Rogers (raof) wrote :

The connect_done variable is tracking whether or not the connection data is going to be modified by the connected() callback; the connection has been done regardless of whether it succeeded or not.

Daniel van Vugt (vanvugt) wrote :

It's a matter of clear communication and readability such that a person reading some small portion of the file does not get the wrong idea. We can obviously do better but it's not a new issue in this branch so not a blocker.

Daniel van Vugt (vanvugt) :
review: Abstain
Kevin DuBois (kdub) wrote :

> It seems like connect_done=true and set_error_message("Connect failed") should
> be mutually exclusive things. Because if the connect failed it's arguably
> never done. Unless done means "attempted". Needs checking...

+1, I think that it would be a bit easier if we didn't have the constraint that the actual Mir{Surface,Connection,etc}* was given out to the client before we have a response from the server. We'd need some sort of misdirection to accommodate the no-wait guarantees of the client api, but imo, would be less confusing. At any rate, beyond scope of this cleanup, lgtm.

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/client/mir_connection.cpp'
2--- src/client/mir_connection.cpp 2015-08-12 06:37:54 +0000
3+++ src/client/mir_connection.cpp 2015-08-21 11:58:59 +0000
4@@ -254,21 +254,12 @@
5
6 void MirConnection::connected(mir_connected_callback callback, void * context)
7 {
8- bool safe_to_callback = true;
9 try
10 {
11 std::lock_guard<decltype(mutex)> lock(mutex);
12
13 if (!connect_result->has_platform() || !connect_result->has_display_configuration())
14- {
15- if (!connect_result->has_error())
16- {
17- // We're handling an error scenario that means we're not sync'd
18- // with the client code - a callback isn't safe (or needed)
19- safe_to_callback = false;
20- set_error_message("Connect failed");
21- }
22- }
23+ set_error_message("Connect failed");
24
25 connect_done = true;
26
27@@ -307,7 +298,7 @@
28 boost::diagnostic_information(e));
29 }
30
31- if (safe_to_callback) callback(this, context);
32+ callback(this, context);
33 connect_wait_handle.result_received();
34 }
35

Subscribers

People subscribed via source and target branches