diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2016-03-10 00:34:59 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2016-03-11 15:03:03 +0100 |
commit | d9596587e294ffde715fb2a7ef877da9f903558a (patch) | |
tree | b8c48038ddb61f7041626bc26fd4a21bfeda7c10 /docs | |
parent | 1322201a43fa4731b0a79dd892bc4a988ae4a428 (diff) |
port-serial: allow completions not in idle
Port serial command completions may be performed in several different places:
* When a cached response is set during command sending.
* When errors happen during command sending.
* When we process a response (i.e. common_input_available())
* When we process a timeout (i.e. port_serial_timed_out())
* When cancelled (i.e. port_serial_response_wait_cancelled())
We're currently safe with the previous logic only because the users of the
serial port explicitly complete operations in idle, which means that whenever
we're processing in a internal callback (e.g. during response or timeout
processing) the serial port object is valid for as long as the callback runs.
But, if we ever end up using the serial port with a not-in-idle completion,
it may happen that if the command is completed within a internal signal callback
the serial port object may get fully closed and unref-ed before exiting the
callback.
We could force a valid port reference to exist as long as the internal signal
is scheduled, but then we may lose the ability to automatically close the port
during a full unref(), as the internal signals are set as long as the port is
open.
So, to cope with this possibility of not-in-idle completion, we instead force
references to be valid whenever we see that a command completion may happen,
which is basically whenever port_serial_got_response() is called; but we only
do that if we're going to use the port object after that, otherwise, we ignore
the problem.
In addition to the problems with the references, we also update the
common_input_available() method so that the source isn't kept if the last
response buffer processing ended up closing the port.
Diffstat (limited to 'docs')
0 files changed, 0 insertions, 0 deletions