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

Gergely Nagy algernon at balabit.hu
Fri Mar 30 13:44:41 CEST 2012


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)
     {
-- 
1.7.9




More information about the syslog-ng mailing list