diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-10-09 22:48:12 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2018-10-09 22:48:12 +0200 |
commit | ced77fcf59ca74bd1fe8cc05dc8286a351e4e11f (patch) | |
tree | 8232cad980aef12d3134b05eb31315fe19b80c28 | |
parent | 89c29c18c95f7f02481a4c620039c4c90d6c1889 (diff) | |
download | libmbim-ced77fcf59ca74bd1fe8cc05dc8286a351e4e11f.tar.gz |
libmbim-glib,device: emit signal before completing transaction task
Completion of transaction tasks is done inline, not in idle, and so a
lot of things may happen during the completion handler, and we may
even find that the input MbimMessage isn't valid any more, as the
message container is the input channel buffer and this buffer may be
closed and recreated during the function error handling...
[09 oct 2018, 22:34:59] [Debug] [/dev/cdc-wdm2] Received message (translated)...
>>>>>> Header:
>>>>>> length = 16
>>>>>> type = function-error (0x80000004)
>>>>>> transaction = 46
>>>>>> Contents:
>>>>>> error = 'NotOpened' (0x00000005)
[09 oct 2018, 22:34:59] [Debug] device not-opened error reported, reopening
[09 oct 2018, 22:34:59] [Debug] [/dev/cdc-wdm2] channel destroyed
[09 oct 2018, 22:34:59] [Debug] opening device...
[09 oct 2018, 22:34:59] [Debug] [/dev/cdc-wdm2] Queried max control message size: 4096
Segmentation fault
Avoid this, just by emitting the error signal before the task
completion.
-rw-r--r-- | src/libmbim-glib/mbim-device.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libmbim-glib/mbim-device.c b/src/libmbim-glib/mbim-device.c index ee87fb4..113fd36 100644 --- a/src/libmbim-glib/mbim-device.c +++ b/src/libmbim-glib/mbim-device.c @@ -700,6 +700,11 @@ process_message (MbimDevice *self, g_free (printable); } + /* Signals are emitted regardless of whether the transaction matched or not */ + error_indication = mbim_message_error_get_error (message); + g_signal_emit (self, signals[SIGNAL_ERROR], 0, error_indication); + g_error_free (error_indication); + if (task) { TransactionContext *ctx; @@ -710,11 +715,6 @@ process_message (MbimDevice *self, ctx->fragments = mbim_message_dup (message); transaction_task_complete_and_free (task, NULL); } - - /* Signals are emitted regardless of whether the transaction matched or not */ - error_indication = mbim_message_error_get_error (message); - g_signal_emit (self, signals[SIGNAL_ERROR], 0, error_indication); - g_error_free (error_indication); return; } |