]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] unix socket: report the socket path in case of bind error
authorWilly Tarreau <w@1wt.eu>
Wed, 14 Oct 2009 13:16:48 +0000 (15:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 14 Oct 2009 18:37:00 +0000 (20:37 +0200)
When an error occurs during binding of the stats unix socket, messages
are far from clear for the user !

src/proto_uxst.c

index 84a38c6aa4d86ce7c746ba0e5b13c1aa2c8527f9..4fceadcd07b2f9cfeeea1c2e9e1398482d08f02a 100644 (file)
@@ -100,36 +100,36 @@ static int create_uxst_socket(const char *path, uid_t uid, gid_t gid, mode_t mod
 
        /* 1. create socket names */
        if (!path[0]) {
-               Alert("Invalid name for a UNIX socket. Aborting.\n");
+               Alert("Invalid empty name for a UNIX socket. Aborting.\n");
                goto err_return;
        }
 
        ret = snprintf(tempname, MAXPATHLEN, "%s.%d.tmp", path, pid);
        if (ret < 0 || ret >= MAXPATHLEN) {
-               Alert("name too long for UNIX socket. Aborting.\n");
+               Alert("name too long for UNIX socket (%s). Aborting.\n", path);
                goto err_return;
        }
 
        ret = snprintf(backname, MAXPATHLEN, "%s.%d.bak", path, pid);
        if (ret < 0 || ret >= MAXPATHLEN) {
-               Alert("name too long for UNIX socket. Aborting.\n");
+               Alert("name too long for UNIX socket (%s). Aborting.\n", path);
                goto err_return;
        }
 
        /* 2. clean existing orphaned entries */
        if (unlink(tempname) < 0 && errno != ENOENT) {
-               Alert("error when trying to unlink previous UNIX socket. Aborting.\n");
+               Alert("error when trying to unlink previous UNIX socket (%s). Aborting.\n", path);
                goto err_return;
        }
 
        if (unlink(backname) < 0 && errno != ENOENT) {
-               Alert("error when trying to unlink previous UNIX socket. Aborting.\n");
+               Alert("error when trying to unlink previous UNIX socket (%s). Aborting.\n", path);
                goto err_return;
        }
 
        /* 3. backup existing socket */
        if (link(path, backname) < 0 && errno != ENOENT) {
-               Alert("error when trying to preserve previous UNIX socket. Aborting.\n");
+               Alert("error when trying to preserve previous UNIX socket (%s). Aborting.\n", path);
                goto err_return;
        }
 
@@ -140,12 +140,12 @@ static int create_uxst_socket(const char *path, uid_t uid, gid_t gid, mode_t mod
 
        sock = socket(PF_UNIX, SOCK_STREAM, 0);
        if (sock < 0) {
-               Alert("cannot create socket for UNIX listener. Aborting.\n");
+               Alert("cannot create socket for UNIX listener (%s). Aborting.\n", path);
                goto err_unlink_back;
        }
 
        if (sock >= global.maxsock) {
-               Alert("socket(): not enough free sockets for UNIX listener. Raise -n argument. Aborting.\n");
+               Alert("socket(): not enough free sockets for UNIX listener (%s). Raise -n argument. Aborting.\n", path);
                goto err_unlink_temp;
        }
 
@@ -156,18 +156,18 @@ static int create_uxst_socket(const char *path, uid_t uid, gid_t gid, mode_t mod
 
        if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
                /* note that bind() creates the socket <tempname> on the file system */
-               Alert("cannot bind socket for UNIX listener. Aborting.\n");
+               Alert("cannot bind socket for UNIX listener (%s). Aborting.\n", path);
                goto err_unlink_temp;
        }
 
        if (((uid != -1 || gid != -1) && (chown(tempname, uid, gid) == -1)) ||
            (mode != 0 && chmod(tempname, mode) == -1)) {
-               Alert("cannot change UNIX socket ownership. Aborting.\n");
+               Alert("cannot change UNIX socket ownership (%s). Aborting.\n", path);
                goto err_unlink_temp;
        }
 
        if (listen(sock, 0) < 0) {
-               Alert("cannot listen to socket for UNIX listener. Aborting.\n");
+               Alert("cannot listen to socket for UNIX listener (%s). Aborting.\n", path);
                goto err_unlink_temp;
        }
 
@@ -177,7 +177,7 @@ static int create_uxst_socket(const char *path, uid_t uid, gid_t gid, mode_t mod
         * backname.
         */
        if (rename(tempname, path) < 0) {
-               Alert("cannot switch final and temporary sockets for UNIX listener. Aborting.\n");
+               Alert("cannot switch final and temporary sockets for UNIX listener (%s). Aborting.\n", path);
                goto err_rename;
        }