libqmi-glib,client: new 'client-valid' property

It may happen that the lifecycle of a QmiDevice and its allocated
QmiClients is managed in a different place of where the QmiClient
commands are run, which may keep a QmiClient reference of its own.

In this setup, it may happen that the QmiDevice is closed and all
clients released while there are still full QmiClient references
around that the client may try to use. When this happens, the client
operation didn't fail with an error, instead it would just issue a
'QMI_IS_DEVICE (self)' failed warning and go on.

    ...
    [/dev/cdc-wdm0] Releasing 'dms' client with flags 'release-cid'...
    [/dev/cdc-wdm0] Unregistered 'dms' client with ID '10'
    [/dev/cdc-wdm0] sent message...
    <<<<<< RAW:
    <<<<<<   length = 17
    <<<<<<   data   = 01:10:00:00:00:00:00:0C:23:00:05:00:01:02:00:02:0A
    [/dev/cdc-wdm0] sent generic request (translated)...
    <<<<<< QMUX:
    <<<<<<   length  = 16
    <<<<<<   flags   = 0x00
    <<<<<<   service = "ctl"
    <<<<<<   client  = 0
    <<<<<< QMI:
    <<<<<<   flags       = "none"
    <<<<<<   transaction = 12
    <<<<<<   tlv_length  = 5
    <<<<<<   message     = "Release CID" (0x0023)
    <<<<<< TLV:
    <<<<<<   type       = "Release Info" (0x01)
    <<<<<<   length     = 2
    <<<<<<   value      = 02:0A
    <<<<<<   translated = [ service = 'dms' cid = '10' ]
    qmi_device_command_full: assertion 'QMI_IS_DEVICE (self)' failed
    <warn>  [062790.772245] checking if connected failed: Transaction timed out
    <debug> [062793.774332] Couldn't refresh CDMA registration status: 'QMI operation failed: Transaction timed out'
    <debug> [062793.774398] Couldn't refresh signal quality: 'Transaction timed out'
    <debug> [062793.774414] Periodic signal checks not rescheduled: disabled
    qmi_device_command_full: assertion 'QMI_IS_DEVICE (self)' failed
    <warn>  [062795.773381] Reloading stats failed: QMI operation failed: Transaction timed out
    <warn>  [062795.773425] checking if connected failed: Transaction timed out
    qmi_device_command_full: assertion 'QMI_IS_DEVICE (self)' failed
    qmi_device_command_full: assertion 'QMI_IS_DEVICE (self)' failed
    ...

We avoid this situation by exposing a new 'client-valid' property that
users may check before running any command.

This same check is now also internally done by all commands so that we
cleanly error out if we detect that the client isn't valid.
5 files changed