pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/41003: gated exits due to syslog to console when tracing is enabled



>Number:         41003
>Category:       pkg
>Synopsis:       gated exits due to syslog to console when tracing is enabled
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 13 07:55:00 +0000 2009
>Originator:     Wolfgang Stukenbrock
>Release:        NetBSD 4.0
>Organization:
Dr. Nagler & Company GmbH
        
>Environment:
        
        
System: NetBSD s012 4.0 NetBSD 4.0 (NSW-S012) #1: Thu Sep 11 12:21:03 CEST 2008 
root@s012:/usr/src/sys/arch/amd64/compile/NSW-S012 amd64
Architecture: x86_64
Machine: amd64
>Description:
        gated seems to analyse errno in an outer loop to see if something has 
failed
        in the procesing before. (I haven't search where it is in the source 
...)
        When tracing is enabled some output will be send to a tracefile and to 
syslog().
        If syslog is routed to the console too, the syslog() call will open 
/dev/console
        and try to write to it. If the console is slow (e.g. a serial line), 
then the
        write() will fail with EAGAIN.
        You can see this if you start gated with ktruss - e.g. "ktruss gated -N 
-f /etc/gated.conf".
        The error writing to /dev/console is in general no problem - a message 
is lost on
        the console. This is OK for the syslog stuff itself.
        But the failed write has set errno to EAGAIN and the check for some 
errors in
        gated detect the EAGAIN, forcing gated to exit.
        This is a strage behaviour for a routing daemon and makes it impossible 
to trace
        configuration problems by using the trace feature of gated.
>How-To-Repeat:
        Enable tracing in gated and setup syslog to send the output to the 
console.
        gated will exit with "Resource temporary unavailable" after a very 
short time.
>Fix:
        A look into the code has shown, that the problem can be fixed by saving 
the variable
        errno prior calling some tracing routines and restore it after tracing 
is done.
        This avoid the exit by any error produced by the tracing stuff.
        The best place I've found for the patch is in trace.h
        There the macro trace_log_tf() is used to send out the information - 
either by
        calling syslog() directly or indirectly via trace_syslog().
        The flowing patch will save the errno prior calling one oth theese 
routines and
        restores the value after it.


--- src/trace.h.orig    2009-03-13 08:23:04.000000000 +0100
+++ src/trace.h 2009-03-13 08:24:02.000000000 +0100
@@ -351,12 +351,12 @@
        if ((trp) && (trp)->tr_file->trf_FILE && 
!BIT_TEST((trp)->tr_control|(cf), TRC_LOGONLY)) { \
             trace_trace((trp), (trp)->tr_control|(cf)); \
        } \
-       if (pri) { \
+       if (pri) { int x_err = errno; \
            if (trace_nosyslog) { \
                trace_syslog((pri)); \
            } else { \
                syslog((pri), trace_buffer); \
-           } \
+           } errno = x_err; \
        } \
        trace_clear(); \
     }

>Unformatted:
        
        


Home | Main Index | Thread Index | Old Index