libqmi-glib,device: make sure transaction is removed from table on early errors
This commit is contained in:
parent
b760b98a5d
commit
c1442b3a7f
|
@ -2754,6 +2754,23 @@ qmi_device_command_finish (QmiDevice *self,
|
|||
G_SIMPLE_ASYNC_RESULT (res)));
|
||||
}
|
||||
|
||||
static void
|
||||
transaction_early_error (QmiDevice *self,
|
||||
Transaction *tr,
|
||||
gboolean stored,
|
||||
GError *error)
|
||||
{
|
||||
g_assert (error);
|
||||
|
||||
if (stored) {
|
||||
/* Match transaction so that we remove it from our tracking table */
|
||||
tr = device_match_transaction (self, tr->message);
|
||||
g_assert (tr);
|
||||
}
|
||||
transaction_complete_and_free (tr, NULL, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
/**
|
||||
* qmi_device_command:
|
||||
* @self: a #QmiDevice.
|
||||
|
@ -2807,8 +2824,7 @@ qmi_device_command (QmiDevice *self,
|
|||
error = g_error_new (QMI_CORE_ERROR,
|
||||
QMI_CORE_ERROR_WRONG_STATE,
|
||||
"Device must be open to send commands");
|
||||
transaction_complete_and_free (tr, NULL, error);
|
||||
g_error_free (error);
|
||||
transaction_early_error (self, tr, FALSE, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2820,8 +2836,7 @@ qmi_device_command (QmiDevice *self,
|
|||
QMI_CORE_ERROR_FAILED,
|
||||
"Cannot send message in service '%s' without a CID",
|
||||
qmi_service_get_string (qmi_message_get_service (message)));
|
||||
transaction_complete_and_free (tr, NULL, error);
|
||||
g_error_free (error);
|
||||
transaction_early_error (self, tr, FALSE, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2829,8 +2844,7 @@ qmi_device_command (QmiDevice *self,
|
|||
* (only applicable if we did version info check when opening) */
|
||||
if (!check_message_supported (self, message, &error)) {
|
||||
g_prefix_error (&error, "Cannot send message: ");
|
||||
transaction_complete_and_free (tr, NULL, error);
|
||||
g_error_free (error);
|
||||
transaction_early_error (self, tr, FALSE, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2838,8 +2852,7 @@ qmi_device_command (QmiDevice *self,
|
|||
raw_message = qmi_message_get_raw (message, &raw_message_len, &error);
|
||||
if (!raw_message) {
|
||||
g_prefix_error (&error, "Cannot get raw message: ");
|
||||
transaction_complete_and_free (tr, NULL, error);
|
||||
g_error_free (error);
|
||||
transaction_early_error (self, tr, FALSE, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2854,11 +2867,13 @@ qmi_device_command (QmiDevice *self,
|
|||
/* Setup context to match response */
|
||||
if (!device_store_transaction (self, tr, transaction_timeout, &error)) {
|
||||
g_prefix_error (&error, "Cannot store transaction: ");
|
||||
transaction_complete_and_free (tr, NULL, error);
|
||||
g_error_free (error);
|
||||
transaction_early_error (self, tr, FALSE, error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* From now on, if we want to complete the transaction with an early error,
|
||||
* it needs to be removed from the tracking table as well. */
|
||||
|
||||
if (qmi_utils_get_traces_enabled ()) {
|
||||
gchar *printable;
|
||||
|
||||
|
@ -2891,8 +2906,7 @@ qmi_device_command (QmiDevice *self,
|
|||
cancellable,
|
||||
&error)) {
|
||||
g_prefix_error (&error, "Cannot create MBIM command: ");
|
||||
transaction_complete_and_free (tr, NULL, error);
|
||||
g_error_free (error);
|
||||
transaction_early_error (self, tr, TRUE, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -2905,10 +2919,8 @@ qmi_device_command (QmiDevice *self,
|
|||
NULL, /* cancellable */
|
||||
&error)) {
|
||||
g_prefix_error (&error, "Cannot write message: ");
|
||||
/* Match transaction so that we remove it from our tracking table */
|
||||
tr = device_match_transaction (self, message);
|
||||
transaction_complete_and_free (tr, NULL, error);
|
||||
g_error_free (error);
|
||||
transaction_early_error (self, tr, TRUE, error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Flush explicitly if correctly written */
|
||||
|
|
Loading…
Reference in New Issue