serial: warn when open/close take longer than 7 seconds

Due to kernel bugs and such.
This commit is contained in:
Dan Williams
2011-06-15 12:50:35 -05:00
parent 884ba2bb09
commit 77fa848820
+10 -2
View File
@@ -745,6 +745,7 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
char *devfile;
const char *device;
struct serial_struct sinfo;
GTimeVal tv_start, tv_end;
g_return_val_if_fail (MM_IS_SERIAL_PORT (self), FALSE);
@@ -759,6 +760,8 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
mm_info ("(%s) opening serial port...", device);
g_get_current_time (&tv_start);
/* Only open a new file descriptor if we weren't given one already */
if (priv->fd < 0) {
devfile = g_strdup_printf ("/dev/%s", device);
@@ -807,6 +810,11 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
ioctl (priv->fd, TIOCSSERIAL, &sinfo);
}
g_get_current_time (&tv_end);
if (tv_end.tv_sec - tv_start.tv_sec > 7)
mm_warn ("(%s): open blocked by driver for more than 7 seconds!", device);
priv->channel = g_io_channel_unix_new (priv->fd);
g_io_channel_set_encoding (priv->channel, NULL, NULL);
priv->watch_id = g_io_add_watch (priv->channel,
@@ -896,8 +904,8 @@ mm_serial_port_close (MMSerialPort *self)
* that data to send before giving up and returning from close().
* Log that. See GNOME bug #630670 for more details.
*/
if (tv_end.tv_sec - tv_start.tv_sec > 20)
mm_warn ("(%s): close blocked by driver for more than 20 seconds!", device);
if (tv_end.tv_sec - tv_start.tv_sec > 7)
mm_warn ("(%s): close blocked by driver for more than 7 seconds!", device);
}
/* Clear the command queue */