Improved diagnostics patch

David Favro lists.samba.org at meta-dynamic.com
Mon Feb 20 13:03:30 GMT 2006


Hi, all --

Here's a small patch that gives better diagnostics on the daemon side if it
fails to start up due to inability to create or bind the socket.
Presently, it gives a log entry indicating that no sockets could be bound,
but crucially does *not* have the system error message (i.e. errno) from
the failed call, making it difficult or impossible to determine the
problem.

I do have a couple of misgivings about the patch, however, in that it seems
that it might emit log messages that look like errors even though the
daemon did successfully bind and start, when there are multiple protocols
available and it fails on one but succeeds on another (quoting from the
code's comments: "if for example the machine knows about IPv6 in the C
library, but not in the kernel").  That said, I think that too much
diagnostic information is usually better than not enough, and I think it
would be rare that spurious messages are emitted.

Also, one can't be sure that the address-family and protocol can always be
printed with a printf-code of "%d", although it compiles without warning on
my machine.  <opinion>This is where choosing a programming language that
supports data encapsulation really helps.</opinion>  The family and protocol
could just be removed from the message, although it is possible to imagine
that, on a multi-protocol box, there could be multiple failures due to
multiple causes, and it would be necessary to match up the diagnostic error
messages.

-- David Favro
lists.samba.org at meta-dynamic dot com
http://meta-dynamic.com

The patch:
--- socket.c.~1.116.~   2006-02-03 13:46:38.000000000 -0500
+++ socket.c    2006-02-20 07:18:11.000000000 -0500
@@ -364,6 +364,7 @@
                           resp->ai_protocol);

                if (s == -1) {
+                       rsyserr(FERROR, errno, "socket(%d,%d)", resp->ai_family, resp->ai_protocol );
                        /* See if there's another address that will work... */
                        continue;
                }
@@ -385,6 +386,7 @@
                /* Now we've got a socket - we need to bind it. */
                if (bind(s, resp->ai_addr, resp->ai_addrlen) < 0) {
                        /* Nope, try another */
+                       rsyserr(FERROR, errno, "bind()" );
                        close(s);
                        continue;
                }


More information about the rsync mailing list