diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-11-30 14:03:31 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-12-12 12:56:47 +0100 |
commit | dc9bbefbc083a328fad0b770d1e716e704c72c65 (patch) | |
tree | 1a4dc17a08e8add583225cddc30856071f822a19 | |
parent | f20922ba9d766bfbb198a3c2e41981b4d9473cfa (diff) |
icera,hso: don't wait to get connected if the primary port is removed
If the primary port is gone (e.g. when going to sleep) and we are just in the
middle of a connection attempt, we won't be able to receive any unsolicited
message regarding the status of the attempt. So, if we detect that the port is
forced to get closed, we'll just treat it as a connection failure.
http://code.google.com/p/chromium-os/issues/detail?id=35391
-rw-r--r-- | plugins/icera/mm-broadband-bearer-icera.c | 30 | ||||
-rw-r--r-- | plugins/option/mm-broadband-bearer-hso.c | 28 | ||||
-rw-r--r-- | src/mm-serial-port.c | 13 | ||||
-rw-r--r-- | src/mm-serial-port.h | 1 |
4 files changed, 71 insertions, 1 deletions
diff --git a/plugins/icera/mm-broadband-bearer-icera.c b/plugins/icera/mm-broadband-bearer-icera.c index 7dce6859..589bdc4e 100644 --- a/plugins/icera/mm-broadband-bearer-icera.c +++ b/plugins/icera/mm-broadband-bearer-icera.c | |||
@@ -50,6 +50,7 @@ struct _MMBroadbandBearerIceraPrivate { | |||
50 | gpointer connect_pending; | 50 | gpointer connect_pending; |
51 | guint connect_pending_id; | 51 | guint connect_pending_id; |
52 | gulong connect_cancellable_id; | 52 | gulong connect_cancellable_id; |
53 | gulong connect_port_closed_id; | ||
53 | 54 | ||
54 | /* Disconnection related */ | 55 | /* Disconnection related */ |
55 | gpointer disconnect_pending; | 56 | gpointer disconnect_pending; |
@@ -624,6 +625,12 @@ connect_timed_out_cb (MMBroadbandBearerIcera *self) | |||
624 | self->priv->connect_cancellable_id = 0; | 625 | self->priv->connect_cancellable_id = 0; |
625 | } | 626 | } |
626 | 627 | ||
628 | /* Remove closed port watch, if found */ | ||
629 | if (ctx && self->priv->connect_port_closed_id) { | ||
630 | g_signal_handler_disconnect (ctx->primary, self->priv->connect_port_closed_id); | ||
631 | self->priv->connect_port_closed_id = 0; | ||
632 | } | ||
633 | |||
627 | /* Cleanup timeout ID */ | 634 | /* Cleanup timeout ID */ |
628 | self->priv->connect_pending_id = 0; | 635 | self->priv->connect_pending_id = 0; |
629 | 636 | ||
@@ -665,6 +672,16 @@ connect_cancelled_cb (GCancellable *cancellable, | |||
665 | } | 672 | } |
666 | 673 | ||
667 | static void | 674 | static void |
675 | forced_close_cb (MMSerialPort *port, | ||
676 | MMBroadbandBearerIcera *self) | ||
677 | { | ||
678 | /* Just treat the forced close event as any other unsolicited message */ | ||
679 | mm_broadband_bearer_icera_report_connection_status ( | ||
680 | self, | ||
681 | MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_CONNECTION_FAILED); | ||
682 | } | ||
683 | |||
684 | static void | ||
668 | ier_query_ready (MMBaseModem *modem, | 685 | ier_query_ready (MMBaseModem *modem, |
669 | GAsyncResult *res, | 686 | GAsyncResult *res, |
670 | Dial3gppContext *ctx) | 687 | Dial3gppContext *ctx) |
@@ -708,7 +725,7 @@ report_connect_status (MMBroadbandBearerIcera *self, | |||
708 | ctx = self->priv->connect_pending; | 725 | ctx = self->priv->connect_pending; |
709 | self->priv->connect_pending = NULL; | 726 | self->priv->connect_pending = NULL; |
710 | 727 | ||
711 | /* Cleanup cancellable and timeout, if any */ | 728 | /* Cleanup cancellable, timeout and port closed watch, if any */ |
712 | if (self->priv->connect_pending_id) { | 729 | if (self->priv->connect_pending_id) { |
713 | g_source_remove (self->priv->connect_pending_id); | 730 | g_source_remove (self->priv->connect_pending_id); |
714 | self->priv->connect_pending_id = 0; | 731 | self->priv->connect_pending_id = 0; |
@@ -720,6 +737,11 @@ report_connect_status (MMBroadbandBearerIcera *self, | |||
720 | self->priv->connect_cancellable_id = 0; | 737 | self->priv->connect_cancellable_id = 0; |
721 | } | 738 | } |
722 | 739 | ||
740 | if (ctx && self->priv->connect_port_closed_id) { | ||
741 | g_signal_handler_disconnect (ctx->primary, self->priv->connect_port_closed_id); | ||
742 | self->priv->connect_port_closed_id = 0; | ||
743 | } | ||
744 | |||
723 | switch (status) { | 745 | switch (status) { |
724 | case MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_UNKNOWN: | 746 | case MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_UNKNOWN: |
725 | break; | 747 | break; |
@@ -845,6 +867,12 @@ activate_ready (MMBaseModem *modem, | |||
845 | G_CALLBACK (connect_cancelled_cb), | 867 | G_CALLBACK (connect_cancelled_cb), |
846 | self, | 868 | self, |
847 | NULL); | 869 | NULL); |
870 | |||
871 | /* If we get the port closed, we treat as a connect error */ | ||
872 | self->priv->connect_port_closed_id = g_signal_connect (ctx->primary, | ||
873 | "forced-close", | ||
874 | G_CALLBACK (forced_close_cb), | ||
875 | self); | ||
848 | } | 876 | } |
849 | 877 | ||
850 | static void | 878 | static void |
diff --git a/plugins/option/mm-broadband-bearer-hso.c b/plugins/option/mm-broadband-bearer-hso.c index 0db9dac8..06858818 100644 --- a/plugins/option/mm-broadband-bearer-hso.c +++ b/plugins/option/mm-broadband-bearer-hso.c | |||
@@ -40,6 +40,7 @@ struct _MMBroadbandBearerHsoPrivate { | |||
40 | gpointer connect_pending; | 40 | gpointer connect_pending; |
41 | guint connect_pending_id; | 41 | guint connect_pending_id; |
42 | gulong connect_cancellable_id; | 42 | gulong connect_cancellable_id; |
43 | gulong connect_port_closed_id; | ||
43 | }; | 44 | }; |
44 | 45 | ||
45 | /*****************************************************************************/ | 46 | /*****************************************************************************/ |
@@ -372,6 +373,11 @@ mm_broadband_bearer_hso_report_connection_status (MMBroadbandBearerHso *self, | |||
372 | self->priv->connect_cancellable_id = 0; | 373 | self->priv->connect_cancellable_id = 0; |
373 | } | 374 | } |
374 | 375 | ||
376 | if (ctx && self->priv->connect_port_closed_id) { | ||
377 | g_signal_handler_disconnect (ctx->primary, self->priv->connect_port_closed_id); | ||
378 | self->priv->connect_port_closed_id = 0; | ||
379 | } | ||
380 | |||
375 | switch (status) { | 381 | switch (status) { |
376 | case MM_BROADBAND_BEARER_HSO_CONNECTION_STATUS_UNKNOWN: | 382 | case MM_BROADBAND_BEARER_HSO_CONNECTION_STATUS_UNKNOWN: |
377 | break; | 383 | break; |
@@ -461,6 +467,12 @@ connect_timed_out_cb (MMBroadbandBearerHso *self) | |||
461 | self->priv->connect_cancellable_id = 0; | 467 | self->priv->connect_cancellable_id = 0; |
462 | } | 468 | } |
463 | 469 | ||
470 | /* Remove closed port watch, if found */ | ||
471 | if (ctx && self->priv->connect_port_closed_id) { | ||
472 | g_signal_handler_disconnect (ctx->primary, self->priv->connect_port_closed_id); | ||
473 | self->priv->connect_port_closed_id = 0; | ||
474 | } | ||
475 | |||
464 | /* Cleanup timeout ID */ | 476 | /* Cleanup timeout ID */ |
465 | self->priv->connect_pending_id = 0; | 477 | self->priv->connect_pending_id = 0; |
466 | 478 | ||
@@ -505,6 +517,16 @@ connect_cancelled_cb (GCancellable *cancellable, | |||
505 | } | 517 | } |
506 | 518 | ||
507 | static void | 519 | static void |
520 | forced_close_cb (MMSerialPort *port, | ||
521 | MMBroadbandBearerHso *self) | ||
522 | { | ||
523 | /* Just treat the forced close event as any other unsolicited message */ | ||
524 | mm_broadband_bearer_hso_report_connection_status ( | ||
525 | self, | ||
526 | MM_BROADBAND_BEARER_HSO_CONNECTION_STATUS_CONNECTION_FAILED); | ||
527 | } | ||
528 | |||
529 | static void | ||
508 | activate_ready (MMBaseModem *modem, | 530 | activate_ready (MMBaseModem *modem, |
509 | GAsyncResult *res, | 531 | GAsyncResult *res, |
510 | MMBroadbandBearerHso *self) | 532 | MMBroadbandBearerHso *self) |
@@ -546,6 +568,12 @@ activate_ready (MMBaseModem *modem, | |||
546 | G_CALLBACK (connect_cancelled_cb), | 568 | G_CALLBACK (connect_cancelled_cb), |
547 | self, | 569 | self, |
548 | NULL); | 570 | NULL); |
571 | |||
572 | /* If we get the port closed, we treat as a connect error */ | ||
573 | self->priv->connect_port_closed_id = g_signal_connect (ctx->primary, | ||
574 | "forced-close", | ||
575 | G_CALLBACK (forced_close_cb), | ||
576 | self); | ||
549 | } | 577 | } |
550 | 578 | ||
551 | static void authenticate (Dial3gppContext *ctx); | 579 | static void authenticate (Dial3gppContext *ctx); |
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c index 04cac88c..87f06e27 100644 --- a/src/mm-serial-port.c +++ b/src/mm-serial-port.c | |||
@@ -57,6 +57,7 @@ enum { | |||
57 | enum { | 57 | enum { |
58 | BUFFER_FULL, | 58 | BUFFER_FULL, |
59 | TIMED_OUT, | 59 | TIMED_OUT, |
60 | FORCED_CLOSE, | ||
60 | 61 | ||
61 | LAST_SIGNAL | 62 | LAST_SIGNAL |
62 | }; | 63 | }; |
@@ -1093,6 +1094,9 @@ mm_serial_port_close_force (MMSerialPort *self) | |||
1093 | /* Mark as having forced the close, so that we don't warn about incorrect | 1094 | /* Mark as having forced the close, so that we don't warn about incorrect |
1094 | * open counts */ | 1095 | * open counts */ |
1095 | priv->forced_close = TRUE; | 1096 | priv->forced_close = TRUE; |
1097 | |||
1098 | /* Notify about the forced close status */ | ||
1099 | g_signal_emit (self, signals[FORCED_CLOSE], 0); | ||
1096 | } | 1100 | } |
1097 | 1101 | ||
1098 | static void | 1102 | static void |
@@ -1670,4 +1674,13 @@ mm_serial_port_class_init (MMSerialPortClass *klass) | |||
1670 | NULL, NULL, | 1674 | NULL, NULL, |
1671 | g_cclosure_marshal_VOID__UINT, | 1675 | g_cclosure_marshal_VOID__UINT, |
1672 | G_TYPE_NONE, 1, G_TYPE_UINT); | 1676 | G_TYPE_NONE, 1, G_TYPE_UINT); |
1677 | |||
1678 | signals[FORCED_CLOSE] = | ||
1679 | g_signal_new ("forced-close", | ||
1680 | G_OBJECT_CLASS_TYPE (object_class), | ||
1681 | G_SIGNAL_RUN_FIRST, | ||
1682 | G_STRUCT_OFFSET (MMSerialPortClass, forced_close), | ||
1683 | NULL, NULL, | ||
1684 | g_cclosure_marshal_VOID__VOID, | ||
1685 | G_TYPE_NONE, 0); | ||
1673 | } | 1686 | } |
diff --git a/src/mm-serial-port.h b/src/mm-serial-port.h index 77db3219..31cd5a78 100644 --- a/src/mm-serial-port.h +++ b/src/mm-serial-port.h | |||
@@ -100,6 +100,7 @@ struct _MMSerialPortClass { | |||
100 | /* Signals */ | 100 | /* Signals */ |
101 | void (*buffer_full) (MMSerialPort *port, const GByteArray *buffer); | 101 | void (*buffer_full) (MMSerialPort *port, const GByteArray *buffer); |
102 | void (*timed_out) (MMSerialPort *port, guint n_consecutive_replies); | 102 | void (*timed_out) (MMSerialPort *port, guint n_consecutive_replies); |
103 | void (*forced_close) (MMSerialPort *port); | ||
103 | }; | 104 | }; |
104 | 105 | ||
105 | GType mm_serial_port_get_type (void); | 106 | GType mm_serial_port_get_type (void); |