[syslog-ng] Critical hang while opening tty

Jean-Baptiste Quenot jbq at caraldi.com
Sun Jun 7 13:58:35 CEST 2009


2009/6/7 Balazs Scheidler <bazsi at balabit.hu>:
>
> That fix was applied to the usertty() driver, are you using that?

Yes I use the default config from Ubuntu:

destination du_all { usertty("*"); };

> But
> yes, as you guessed right, the open() call was not expected to block,
> thus it is not protected by the alarm() call. I didn't know that even
> open might block.
>
> The patch below makes the open() call nonblocking, which means that if
> the tty is blocked, the message will be dropped. But this is probably
> the only sane thing to do.
>
> diff --git a/src/afuser.c b/src/afuser.c
> index e3aa50a..245cdcf 100644
> --- a/src/afuser.c
> +++ b/src/afuser.c
> @@ -95,7 +95,7 @@ afuser_dd_queue(LogPipe *s, LogMessage *msg, const LogPathOptions *path_options)
>           else
>             line[0] = 0;
>           strncat(line, ut->ut_line, sizeof(line));
> -          fd = open(line, O_NOCTTY | O_APPEND | O_WRONLY);
> +          fd = open(line, O_NOCTTY | O_APPEND | O_WRONLY | O_NONBLOCK);
>           if (fd != -1)
>             {
>               alarm_set(10);
>
> I've also committed this to syslog-ng 3.0 tree as this patch:
>
> commit 75c5000a4d6ea6ab04e4f2158e6008dec0a1cdcd
> Author: Balazs Scheidler <bazsi at balabit.hu>
> Date:   Sun Jun 7 11:47:51 2009 +0200
>
>    [afuser] open the tty in nonblocking mode to avoid blocking on serial lines
>
>    Reported-By: Jean-Baptiste Quenot

Great!  I will try the patch.  As I don't control the hardware of my
dedicated servers it's hard to know why the serial line is blocked,
and I don't even have access to those ttys, I'm only using the
pseudo-devices pts/* allocated when connecting through SSH.

Thanks for you great work!
-- 
Jean-Baptiste Quenot
http://jbq.caraldi.com/


More information about the syslog-ng mailing list