<div dir="ltr">Heads up!<div><a href="mailto:benchan@chromium.org">benchan@chromium.org</a> had some offline comments.</div><div>I'll submit an updated patch set (mostly on Monday).</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Jun 13, 2014 at 2:29 PM, Prathmesh Prabhu Chromium <span dir="ltr"><<a href="mailto:pprabhu@chromium.org" target="_blank">pprabhu@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Trace from a successful disconnect:<div><br></div><div><div>2014-06-13T21:50:08.819297+01:00 localhost ModemManager[7467]: <debug> Disconnecting bearer '/org/freedesktop/ModemManager1/Bearer/0'</div>
<div>2014-06-13T21:50:08.819403+01:00 localhost ModemManager[7467]: <info> Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connected -> disconnecting)</div><div>2014-06-13T21:50:08.820824+01:00 localhost ModemManager[7467]: <debug> Launching disconnection on data port (net/wwan0)</div>
<div>2014-06-13T21:50:08.821363+01:00 localhost ModemManager[7467]: [/dev/cdc-wdm0] Sent message...#012<<<<<< RAW:#012<<<<<< length = 108#012<<<<<< data = 03:00:00:00:6C:00:00:00:16:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:01:00:00:00:3C:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:7E:5E:2A:7E:4E:6F:72:72:73:6B:65:6E:7E:5E:2A:7E</div>
<div>2014-06-13T21:50:08.821427+01:00 localhost ModemManager[7467]: [/dev/cdc-wdm0] Sent message (translated)...#012<<<<<< Header:#012<<<<<< length = 108#012<<<<<< type = command (0x00000003)#012<<<<<< transaction = 22#012<<<<<< Fragment header:#012<<<<<< total = 1#012<<<<<< current = 0#012<<<<<< Contents:#012<<<<<< service = 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012<<<<<< cid = 'connect' (0x0000000c)#012<<<<<< type = 'set' (0x00000001)</div>
<div>2014-06-13T21:50:08.824002+01:00 localhost ModemManager[7467]: [/dev/cdc-wdm0] Received message...#012>>>>>> RAW:#012>>>>>> length = 84#012>>>>>> data = 03:00:00:80:54:00:00:00:16:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:00:00:00:00:24:00:00:00:00:00:00:00:03:00:00:00:00:00:00:00:00:00:00:00:7E:5E:2A:7E:4E:6F:72:72:73:6B:65:6E:7E:5E:2A:7E:00:00:00:00</div>
<div>2014-06-13T21:50:08.824038+01:00 localhost ModemManager[7467]: [/dev/cdc-wdm0] Received message (translated)...#012>>>>>> Header:#012>>>>>> length = 84#012>>>>>> type = command-done (0x80000003)#012>>>>>> transaction = 22#012>>>>>> Fragment header:#012>>>>>> total = 1#012>>>>>> current = 0#012>>>>>> Contents:#012>>>>>> status error = 'None' (0x00000000)#012>>>>>> service = 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012>>>>>> cid = 'connect' (0x0000000c)</div>
<div>2014-06-13T21:50:08.824053+01:00 localhost ModemManager[7467]: <debug> Session ID '0': deactivated</div><div>2014-06-13T21:50:08.824061+01:00 localhost ModemManager[7467]: <debug> (wwan0): port now disconnected</div>
<div>2014-06-13T21:50:08.824070+01:00 localhost ModemManager[7467]: <debug> Disconnected bearer '/org/freedesktop/ModemManager1/Bearer/0'</div><div>2014-06-13T21:50:08.824078+01:00 localhost ModemManager[7467]: <info> Modem /org/freedesktop/ModemManager1/Modem/0: state changed (disconnecting -> registered)</div>
</div><div><br></div><div><br></div><div>Trace from a failed disconnect (simulated by reducing the timeout to 1 seconds (that ought to be enough for everybody, right? ;) ).</div><div>The second attempt to disconnect hits the CONTEXT_NOT_ACTIVATED error, and succeeds.</div>
<div><br></div><div><div>2014-06-13T21:41:32.436382+01:00 localhost ModemManager[25314]: <debug> Disconnecting bearer '/org/freedesktop/ModemManager1/Bearer/0'</div><div>2014-06-13T21:41:32.436436+01:00 localhost ModemManager[25314]: <info> Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connected -> disconnecting)</div>
<div>2014-06-13T21:41:32.437900+01:00 localhost ModemManager[25314]: <debug> Launching disconnection on data port (net/wwan0)</div><div>2014-06-13T21:41:32.438038+01:00 localhost ModemManager[25314]: [/dev/cdc-wdm0] Sent message...#012<<<<<< RAW:#012<<<<<< length = 108#012<<<<<< data = 03:00:00:00:6C:00:00:00:16:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:01:00:00:00:3C:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:7E:5E:2A:7E:4E:6F:72:72:73:6B:65:6E:7E:5E:2A:7E</div>
<div>2014-06-13T21:41:32.438054+01:00 localhost ModemManager[25314]: [/dev/cdc-wdm0] Sent message (translated)...#012<<<<<< Header:#012<<<<<< length = 108#012<<<<<< type = command (0x00000003)#012<<<<<< transaction = 22#012<<<<<< Fragment header:#012<<<<<< total = 1#012<<<<<< current = 0#012<<<<<< Contents:#012<<<<<< service = 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012<<<<<< cid = 'connect' (0x0000000c)#012<<<<<< type = 'set' (0x00000001)</div>
<div>2014-06-13T21:41:33.438774+01:00 localhost ModemManager[25314]: <debug> Couldn't disconnect bearer '/org/freedesktop/ModemManager1/Bearer/0'</div><div>2014-06-13T21:41:33.438856+01:00 localhost ModemManager[25314]: <info> Modem /org/freedesktop/ModemManager1/Modem/0: state changed (disconnecting -> connected)</div>
<div>2014-06-13T21:41:38.801220+01:00 localhost ModemManager[25314]: [/dev/cdc-wdm0] Received message...#012>>>>>> RAW:#012>>>>>> length = 84#012>>>>>> data = 03:00:00:80:54:00:00:00:16:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:00:00:00:00:24:00:00:00:00:00:00:00:03:00:00:00:00:00:00:00:00:00:00:00:7E:5E:2A:7E:4E:6F:72:72:73:6B:65:6E:7E:5E:2A:7E:00:00:00:00</div>
<div>2014-06-13T21:41:38.801294+01:00 localhost ModemManager[25314]: [/dev/cdc-wdm0] No transaction matched in received message</div><div>2014-06-13T21:41:38.801314+01:00 localhost ModemManager[25314]: [/dev/cdc-wdm0] Received unexpected message (translated)...#012>>>>>> Header:#012>>>>>> length = 84#012>>>>>> type = command-done (0x80000003)#012>>>>>> transaction = 22#012>>>>>> Fragment header:#012>>>>>> total = 1#012>>>>>> current = 0#012>>>>>> Contents:#012>>>>>> status error = 'None' (0x00000000)#012>>>>>> service = 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012>>>>>> cid = 'connect' (0x0000000c)</div>
<div>2014-06-13T21:41:45.368826+01:00 localhost ModemManager[25314]: <debug> Disconnecting bearer '/org/freedesktop/ModemManager1/Bearer/0'</div><div>2014-06-13T21:41:45.369408+01:00 localhost ModemManager[25314]: <info> Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connected -> disconnecting)</div>
<div>2014-06-13T21:41:45.370606+01:00 localhost ModemManager[25314]: <debug> Launching disconnection on data port (net/wwan0)</div><div>2014-06-13T21:41:45.370642+01:00 localhost ModemManager[25314]: [/dev/cdc-wdm0] Sent message...#012<<<<<< RAW:#012<<<<<< length = 108#012<<<<<< data = 03:00:00:00:6C:00:00:00:17:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:01:00:00:00:3C:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:7E:5E:2A:7E:4E:6F:72:72:73:6B:65:6E:7E:5E:2A:7E</div>
<div>2014-06-13T21:41:45.370656+01:00 localhost ModemManager[25314]: [/dev/cdc-wdm0] Sent message (translated)...#012<<<<<< Header:#012<<<<<< length = 108#012<<<<<< type = command (0x00000003)#012<<<<<< transaction = 23#012<<<<<< Fragment header:#012<<<<<< total = 1#012<<<<<< current = 0#012<<<<<< Contents:#012<<<<<< service = 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012<<<<<< cid = 'connect' (0x0000000c)#012<<<<<< type = 'set' (0x00000001)</div>
<div>2014-06-13T21:41:45.373771+01:00 localhost ModemManager[25314]: [/dev/cdc-wdm0] Received message...#012>>>>>> RAW:#012>>>>>> length = 84#012>>>>>> data = 03:00:00:80:54:00:00:00:17:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:10:00:00:00:24:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00</div>
<div>2014-06-13T21:41:45.373805+01:00 localhost ModemManager[25314]: [/dev/cdc-wdm0] Received message (translated)...#012>>>>>> Header:#012>>>>>> length = 84#012>>>>>> type = command-done (0x80000003)#012>>>>>> transaction = 23#012>>>>>> Fragment header:#012>>>>>> total = 1#012>>>>>> current = 0#012>>>>>> Contents:#012>>>>>> status error = 'ContextNotActivated' (0x00000010)#012>>>>>> service = 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012>>>>>> cid = 'connect' (0x0000000c)</div>
<div>2014-06-13T21:41:45.373819+01:00 localhost ModemManager[25314]: <debug> Session ID '0' already disconnected.</div><div>2014-06-13T21:41:45.373828+01:00 localhost ModemManager[25314]: <debug> (wwan0): port now disconnected</div>
<div>2014-06-13T21:41:45.373837+01:00 localhost ModemManager[25314]: <debug> Disconnected bearer '/org/freedesktop/ModemManager1/Bearer/0'</div></div><div><br></div><div><br></div></div><div class="HOEnZb">
<div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Jun 13, 2014 at 2:22 PM, <span dir="ltr"><<a href="mailto:pprabhu@chromium.org" target="_blank">pprabhu@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Prathmesh Prabhu <<a href="mailto:pprabhu@chromium.org" target="_blank">pprabhu@chromium.org</a>><br>
<br>
If the modem responds with MBIM_STATUS_ERROR_CONTEXT_NOT_ACTIVATED, take it to<br>
mean that the bearer has already been disconnected.<br>
---<br>
src/mm-bearer-mbim.c | 61 +++++++++++++++++++++++++++++++---------------------<br>
1 file changed, 37 insertions(+), 24 deletions(-)<br>
<br>
diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c<br>
index b1e3176..cc658ee 100644<br>
--- a/src/mm-bearer-mbim.c<br>
+++ b/src/mm-bearer-mbim.c<br>
@@ -950,35 +950,48 @@ disconnect_set_ready (MbimDevice *device,<br>
guint32 nw_error;<br>
<br>
response = mbim_device_command_finish (device, res, &error);<br>
- if (response &&<br>
- (mbim_message_command_done_get_result (response, &error) ||<br>
- error->code == MBIM_STATUS_ERROR_FAILURE)) {<br>
+ if (response) {<br>
GError *inner_error = NULL;<br>
+ gboolean result = FALSE, parsed_result = FALSE;<br>
+<br>
+ result = mbim_message_command_done_get_result(response, &error);<br>
+ /* Parse the response only for the cases we need to */<br>
+ if (result ||<br>
+ error->code == MBIM_STATUS_ERROR_FAILURE ||<br>
+ error->code == MBIM_STATUS_ERROR_CONTEXT_NOT_ACTIVATED) {<br>
+ parsed_result = mbim_message_connect_response_parse (<br>
+ response,<br>
+ &session_id,<br>
+ &activation_state,<br>
+ NULL, /* voice_call_state */<br>
+ NULL, /* ip_type */<br>
+ NULL, /* context_type */<br>
+ &nw_error,<br>
+ &inner_error);<br>
+ }<br>
<br>
- if (mbim_message_connect_response_parse (<br>
- response,<br>
- &session_id,<br>
- &activation_state,<br>
- NULL, /* voice_call_state */<br>
- NULL, /* ip_type */<br>
- NULL, /* context_type */<br>
- &nw_error,<br>
- &inner_error)) {<br>
+ /* Now handle different response / error cases */<br>
+ if (result && parsed_result) {<br>
+ mm_dbg ("Session ID '%u': %s",<br>
+ session_id,<br>
+ mbim_activation_state_get_string (activation_state));<br>
+ } else if (error->code == MBIM_STATUS_ERROR_CONTEXT_NOT_ACTIVATED) {<br>
+ mm_dbg ("Session ID '%u' already disconnected.", session_id);<br>
+ g_clear_error (&error);<br>
+ g_clear_error (&inner_error);<br>
+ } else if (error->code == MBIM_STATUS_ERROR_FAILURE) {<br>
+ /* This is the only case when nw_error may be set */<br>
if (nw_error) {<br>
- if (error)<br>
- g_error_free (error);<br>
+ g_error_free (error);<br>
error = mm_mobile_equipment_error_from_mbim_nw_error (nw_error);<br>
- } else<br>
- mm_dbg ("Session ID '%u': %s",<br>
- session_id,<br>
- mbim_activation_state_get_string (activation_state));<br>
- } else {<br>
- /* Prefer the error from the result to the parsing error */<br>
- if (!error)<br>
- error = inner_error;<br>
- else<br>
- g_error_free (inner_error);<br>
+ }<br>
+ } /* else: Some other error->code we don't care about OR (result && !parsed_result) */<br>
+<br>
+ /* Give precedence to original error over parsing error */<br>
+ if (!error && inner_error) {<br>
+ error = inner_error;<br>
}<br>
+ g_clear_error(&inner_error);<br>
}<br>
<br>
if (response)<br>
<span><font color="#888888">--<br>
2.0.0.526.g5318336<br>
<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>