On Wed, 2014-10-08 at 00:29 +0200, Aleksander Morgado wrote:
> On Tue, Oct 7, 2014 at 11:06 PM, Dan Williams <d...@redhat.com> wrote:
> > 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.
> 
> Looks good to me; I'd get it also in the mm-1-4 branch as well.

Pretty sure I did that already...

Dan

> > ---
> >  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
> >
> >
> 
> 
> 


_______________________________________________
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to