summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2014-12-28 18:42:04 +0100
committerAleksander Morgado <aleksander@aleksander.es>2014-12-28 18:45:06 +0100
commit20fedf79c9b4e2463d31ba5c1c75bd37d0a835f9 (patch)
tree501ccd2b5b1c211e612ef25159ee45bf56ce0620
parent1eb52758833dfbf7431f979f1f28ce4beacf3072 (diff)
downloadlibmbim-20fedf79c9b4e2463d31ba5c1c75bd37d0a835f9.tar.gz
libmbim-glib,proxy: translate device wrong-state errors into function not-opened errorsaleksander/function-error-in-transaction
We're forcing close the MbimDevice whenever we detect a not-opened error; so if we afterwards get more commands from the clients, don't just timeout the requests, instead return our own generated function error messages specifying not-opened.
-rw-r--r--src/libmbim-glib/mbim-proxy.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libmbim-glib/mbim-proxy.c b/src/libmbim-glib/mbim-proxy.c
index 2670baa..070a407 100644
--- a/src/libmbim-glib/mbim-proxy.c
+++ b/src/libmbim-glib/mbim-proxy.c
@@ -836,6 +836,13 @@ device_service_subscribe_list_set_ready (MbimDevice *device,
tmp_response = mbim_device_command_finish (device, res, &error);
if (!tmp_response) {
+ /* Translate a MbimDevice wrong state error into a Not-Opened function error. */
+ if (g_error_matches (error, MBIM_CORE_ERROR, MBIM_CORE_ERROR_WRONG_STATE)) {
+ request->response = mbim_message_function_error_new (mbim_message_get_transaction_id (request->message), MBIM_PROTOCOL_ERROR_NOT_OPENED);
+ request_complete_and_free (request);
+ return;
+ }
+
g_debug ("sending request to device failed: %s", error->message);
g_error_free (error);
/* Don't disconnect client, just let the request timeout in its side */
@@ -910,6 +917,13 @@ device_command_ready (MbimDevice *device,
request->response = mbim_device_command_finish (device, res, &error);
if (!request->response) {
+ /* Translate a MbimDevice wrong state error into a Not-Opened function error. */
+ if (g_error_matches (error, MBIM_CORE_ERROR, MBIM_CORE_ERROR_WRONG_STATE)) {
+ request->response = mbim_message_function_error_new (request->original_transaction_id, MBIM_PROTOCOL_ERROR_NOT_OPENED);
+ request_complete_and_free (request);
+ return;
+ }
+
g_debug ("sending request to device failed: %s", error->message);
g_error_free (error);
/* Don't disconnect client, just let the request timeout in its side */