From a06b3f20cafab2ff2d1de16553f7ff578a9b761b Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 1 Jan 2010 20:52:15 -0600 Subject: [PATCH] serial: prevent "hangs" by limiting EAGAIN retries on serial writes MM would appear to hang sometimes when writing to serial devices but in reality was just retrying the write too many times. Make the retry limit time-based so MM doesn't hang but times the attempt out instead. --- src/mm-serial-port.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c index 3abd5619..2600ae51 100644 --- a/src/mm-serial-port.c +++ b/src/mm-serial-port.c @@ -439,6 +439,10 @@ mm_serial_port_send_command (MMSerialPort *self, serial_debug (self, "-->", priv->command->str, -1); + /* Only accept about 3 seconds of EAGAIN */ + if (priv->send_delay > 0) + eagain_count = 3000000 / priv->send_delay; + s = priv->command->str; while (*s) { status = write (priv->fd, s, 1);