[PATCH] serial-port: warn if ioctl(TIOCSSERIAL) fails to set closing_wait
Aleksander Morgado
aleksander at lanedo.com
Fri Jul 5 06:01:42 PDT 2013
On 05/07/13 09:51, Ben Chan wrote:
> Prints out a warning if ioctl(TIOCSSERIAL) fails to set closing_wait to
> none. This helps debug issues when a serial driver does not support or
> properly handle closing_wait, which may cause closing of the serial port
> to block.
> ---
Instead of printing the errno value, better probably to print the error
string instead, i.e. with g_strerror (errno).
> src/mm-serial-port.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c
> index 6482835..23a9815 100644
> --- a/src/mm-serial-port.c
> +++ b/src/mm-serial-port.c
> @@ -940,7 +940,9 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
> */
> if (ioctl (priv->fd, TIOCGSERIAL, &sinfo) == 0) {
> sinfo.closing_wait = ASYNC_CLOSING_WAIT_NONE;
> - ioctl (priv->fd, TIOCSSERIAL, &sinfo);
> + if (ioctl (priv->fd, TIOCSSERIAL, &sinfo) < 0)
> + mm_warn ("(%s): couldn't set serial port closing_wait to none; errno %d",
> + device, errno);
> }
>
> g_get_current_time (&tv_end);
> @@ -1030,7 +1032,9 @@ mm_serial_port_close (MMSerialPort *self)
> if (sinfo.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
> mm_warn ("(%s): serial port closing_wait was reset!", device);
> sinfo.closing_wait = ASYNC_CLOSING_WAIT_NONE;
> - (void) ioctl (priv->fd, TIOCSSERIAL, &sinfo);
> + if (ioctl (priv->fd, TIOCSSERIAL, &sinfo) < 0)
> + mm_warn ("(%s): couldn't set serial port closing_wait to none; errno %d",
> + device, errno);
> }
> }
>
>
--
Aleksander
More information about the ModemManager-devel
mailing list