if (!mir_connection_is_valid(connection)) { mir_connection_release(connection); confuse_reader(); }

Bug #1401829 reported by Daniel van Vugt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mir
Triaged
Medium
Unassigned
mir (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

if (!mir_connection_is_valid(connection))
{
    mir_connection_release(connection);
    confuse_reader();
}

Apparently we've designed the client API such that even invalid connections need to be released. This is confusing because an "invalid" object is not something that normally needs releasing.

I'm told this is because the connection still represents an error object which needs releasing. This is a somewhat valid excuse, but we still have an ambiguity that needs solving:

If a connection is "invalid" due to being an uninitialized pointer then we need to stop the user from calling mir_connection_release (which will probably crash). If the connection is "invalid" due to proper initialization but a failed connection then indeed something still needs freeing.

Even if we solve this in libmirclient with some internal mir_connection_is_really_truly_valid(), then the issue of a confusing API design that's non-obvious and people are likely to mis-use remains... so something needs improving in the design and/or naming. Not just documentation.

Suggestion: If we do keep the current behaviour, then we could solve the confusion just by renaming:
   mir_connection_is_valid
to
   mir_connection_is_connected

Tags: clientapi
Revision history for this message
Michał Sawicz (saviq) wrote :

Syncing task from Mir.

Changed in mir (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.