[syslog-ng] [PATCH] afsocket: Do not die if a destination is not resolvable at startup.

Balazs Scheidler bazsi at balabit.hu
Sat Mar 31 22:13:19 CEST 2012


I think this is already implemented in 3.4 in a different way, this was
the patch that introduced the change:

commit 775af1b8ead493198c1e3cea1edf64909d8a72b2
Author: Balazs Scheidler <bazsi at balabit.hu>
Date:   Sat Oct 29 20:15:35 2011 +0200

    afsocket: handle DNS failures as if it was a connection failure
    
    Instead of preventing the startup completely.
    
    Reported-By: Heiko Gerstung <heiko at am-anger-1.de>
    Signed-off-by: Balazs Scheidler <bazsi at balabit.hu>



On Fri, 2012-03-30 at 13:44 +0200, Gergely Nagy wrote:
> If a destination cannot be resolved at init time, do not panic, just
> bail out, but otherwise pretend we succeeded: after time_reopen, we'll
> retry anyway!
> 
> And on that note, teach afsocket_dd_start_connect() to call
> afsocket_dd_apply_transport() if our fd is -1 (ie, not connected).
> 
> Reported-by: Peter Palfrader <weasel at debian.org>
> Signed-off-by: Gergely Nagy <algernon at balabit.hu>
> ---
>  modules/afsocket/afinet.c   |    2 +-
>  modules/afsocket/afsocket.c |    8 +++++---
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/modules/afsocket/afinet.c b/modules/afsocket/afinet.c
> index f83ff38..a7d3635 100644
> --- a/modules/afsocket/afinet.c
> +++ b/modules/afsocket/afinet.c
> @@ -498,7 +498,7 @@ afinet_dd_apply_transport(AFSocketDestDriver *s)
>  
>    if ((self->bind_ip && !resolve_hostname(&self->super.bind_addr, self->bind_ip)) ||
>        !resolve_hostname(&self->super.dest_addr, self->super.hostname))
> -    return FALSE;
> +    return TRUE;
>  
>    afinet_set_port(self->super.dest_addr, self->dest_port ? : default_dest_port, self->super.flags & AFSOCKET_DGRAM ? "udp" : "tcp");
>  
> diff --git a/modules/afsocket/afsocket.c b/modules/afsocket/afsocket.c
> index ae9c5c2..095f5a5 100644
> --- a/modules/afsocket/afsocket.c
> +++ b/modules/afsocket/afsocket.c
> @@ -1103,6 +1103,11 @@ afsocket_dd_start_connect(AFSocketDestDriver *self)
>    gchar buf1[MAX_SOCKADDR_STRING], buf2[MAX_SOCKADDR_STRING];
>  
>    main_loop_assert_main_thread();
> +
> +  if (self->fd == -1)
> +    if (!afsocket_dd_apply_transport(self))
> +      return FALSE;
> +
>    if (!afsocket_open_socket(self->bind_addr, !!(self->flags & AFSOCKET_STREAM), &sock))
>      {
>        return FALSE;
> @@ -1169,10 +1174,7 @@ afsocket_dd_init(LogPipe *s)
>  
>    /* these fields must be set up by apply_transport, so let's check if it indeed did */
>    g_assert(self->transport);
> -  g_assert(self->bind_addr);
> -  g_assert(self->dest_addr);
>    g_assert(self->hostname);
> -  g_assert(self->dest_name);
>  
>    if (cfg)
>      {

-- 
Bazsi




More information about the syslog-ng mailing list