diff options
author | Dan Williams <dcbw@redhat.com> | 2012-11-08 12:17:00 -0600 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2012-11-14 11:03:56 -0600 |
commit | e798b6e663131aaabc8919de2a46eb2f58d43aa0 (patch) | |
tree | 0f1e49af0afdb48bd1ec4afc61ead12e15b12a0a | |
parent | 191eabe952031b5dcc86e92c993d6bfbef101f3f (diff) |
serial: fix warning when driver doesn't support closing_wait (bgo #630670)
It appears that GIOChannel might also do some flushing, so make sure
our warning captures that delay if there is one. Also be paranoid
and make sure nothing reset our closing_wait value.
-rw-r--r-- | src/mm-serial-port.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c index 568f4e4a..ce2dfebd 100644 --- a/src/mm-serial-port.c +++ b/src/mm-serial-port.c | |||
@@ -902,7 +902,7 @@ mm_serial_port_open (MMSerialPort *self, GError **error) | |||
902 | 902 | ||
903 | /* Don't wait for pending data when closing the port; this can cause some | 903 | /* Don't wait for pending data when closing the port; this can cause some |
904 | * stupid devices that don't respond to URBs on a particular port to hang | 904 | * stupid devices that don't respond to URBs on a particular port to hang |
905 | * for 30 seconds when probin fails. | 905 | * for 30 seconds when probing fails. See GNOME bug #630670. |
906 | */ | 906 | */ |
907 | if (ioctl (priv->fd, TIOCGSERIAL, &sinfo) == 0) { | 907 | if (ioctl (priv->fd, TIOCGSERIAL, &sinfo) == 0) { |
908 | sinfo.closing_wait = ASYNC_CLOSING_WAIT_NONE; | 908 | sinfo.closing_wait = ASYNC_CLOSING_WAIT_NONE; |
@@ -980,11 +980,25 @@ mm_serial_port_close (MMSerialPort *self) | |||
980 | 980 | ||
981 | if (priv->fd >= 0) { | 981 | if (priv->fd >= 0) { |
982 | GTimeVal tv_start, tv_end; | 982 | GTimeVal tv_start, tv_end; |
983 | struct serial_struct sinfo; | ||
983 | 984 | ||
984 | mm_info ("(%s) closing serial port...", device); | 985 | mm_info ("(%s) closing serial port...", device); |
985 | 986 | ||
986 | mm_port_set_connected (MM_PORT (self), FALSE); | 987 | mm_port_set_connected (MM_PORT (self), FALSE); |
987 | 988 | ||
989 | /* Paranoid: ensure our closing_wait value is still set so we ignore | ||
990 | * pending data when closing the port. See GNOME bug #630670. | ||
991 | */ | ||
992 | if (ioctl (priv->fd, TIOCGSERIAL, &sinfo) == 0) { | ||
993 | if (sinfo.closing_wait != ASYNC_CLOSING_WAIT_NONE) { | ||
994 | mm_warn ("(%s): serial port closing_wait was reset!", device); | ||
995 | sinfo.closing_wait = ASYNC_CLOSING_WAIT_NONE; | ||
996 | (void) ioctl (priv->fd, TIOCSSERIAL, &sinfo); | ||
997 | } | ||
998 | } | ||
999 | |||
1000 | g_get_current_time (&tv_start); | ||
1001 | |||
988 | if (priv->channel) { | 1002 | if (priv->channel) { |
989 | g_source_remove (priv->watch_id); | 1003 | g_source_remove (priv->watch_id); |
990 | priv->watch_id = 0; | 1004 | priv->watch_id = 0; |
@@ -993,8 +1007,6 @@ mm_serial_port_close (MMSerialPort *self) | |||
993 | priv->channel = NULL; | 1007 | priv->channel = NULL; |
994 | } | 1008 | } |
995 | 1009 | ||
996 | g_get_current_time (&tv_start); | ||
997 | |||
998 | tcsetattr (priv->fd, TCSANOW, &priv->old_t); | 1010 | tcsetattr (priv->fd, TCSANOW, &priv->old_t); |
999 | tcflush (priv->fd, TCIOFLUSH); | 1011 | tcflush (priv->fd, TCIOFLUSH); |
1000 | close (priv->fd); | 1012 | close (priv->fd); |