[MM PATCH] port-serial: fix forced closing after b28230411
- From: Dan Williams <dcbw redhat com>
- To: Aleksander Morgado <aleksander aleksander es>
- Cc: networkmanager-list gnome org
- Subject: [MM PATCH] port-serial: fix forced closing after b28230411
- Date: Tue, 07 Oct 2014 16:06:16 -0500
b28230411 moved up the self->priv->forced_close = TRUE, which
caused mm_port_serial_close() to just return without actually
closing the port and cleaning up.
Also, cancel the reopen separately from closing the port since
the two operations are actually independent of each other.
---
src/mm-port-serial.c | 43 +++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/mm-port-serial.c b/src/mm-port-serial.c
index 9b74900..3af1b8e 100644
--- a/src/mm-port-serial.c
+++ b/src/mm-port-serial.c
@@ -1270,33 +1270,31 @@ mm_port_serial_is_open (MMPortSerial *self)
{
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (MM_IS_PORT_SERIAL (self), FALSE);
return !!self->priv->open_count;
}
-void
-mm_port_serial_close (MMPortSerial *self)
+static void
+_close_internal (MMPortSerial *self, gboolean force)
{
const char *device;
int i;
g_return_if_fail (MM_IS_PORT_SERIAL (self));
- /* If we forced closing the port, open_count will be 0 already.
- * Just return without issuing any warning */
- if (self->priv->forced_close)
- return;
-
- g_return_if_fail (self->priv->open_count > 0);
+ if (force)
+ self->priv->open_count = 0;
+ else {
+ g_return_if_fail (self->priv->open_count > 0);
+ self->priv->open_count--;
+ }
device = mm_port_get_device (MM_PORT (self));
- self->priv->open_count--;
-
mm_dbg ("(%s) device open count is %d (close)", device, self->priv->open_count);
if (self->priv->open_count > 0)
return;
if (self->priv->connected_id) {
g_signal_handler_disconnect (self, self->priv->connected_id);
@@ -1398,43 +1396,48 @@ mm_port_serial_close (MMPortSerial *self)
self->priv->cancellable_id);
self->priv->cancellable_id = 0;
}
g_clear_object (&self->priv->cancellable);
}
+void
+mm_port_serial_close (MMPortSerial *self)
+{
+ g_return_if_fail (MM_IS_PORT_SERIAL (self));
+
+ if (!self->priv->forced_close)
+ _close_internal (self, FALSE);
+}
+
static void
port_serial_close_force (MMPortSerial *self)
{
- g_return_if_fail (self != NULL);
g_return_if_fail (MM_IS_PORT_SERIAL (self));
/* If already forced to close, return */
if (self->priv->forced_close)
return;
mm_dbg ("(%s) forced to close port", mm_port_get_device (MM_PORT (self)));
/* Mark as having forced the close, so that we don't warn about incorrect
* open counts */
self->priv->forced_close = TRUE;
- /* If already closed, done */
- if (!self->priv->open_count && !self->priv->reopen_ctx)
- return;
-
/* Cancel port reopening if one is running */
port_serial_reopen_cancel (self);
- /* Force the port to close */
- self->priv->open_count = 1;
- mm_port_serial_close (self);
+ /* If already closed, done */
+ if (self->priv->open_count > 0) {
+ _close_internal (self, TRUE);
- /* Notify about the forced close status */
- g_signal_emit (self, signals[FORCED_CLOSE], 0);
+ /* Notify about the forced close status */
+ g_signal_emit (self, signals[FORCED_CLOSE], 0);
+ }
}
/*****************************************************************************/
/* Reopen */
typedef struct {
MMPortSerial *self;
--
1.9.3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]