]> 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:40:41 +0000 (20:40 +0200)
When an error occurs during binding of the stats unix socket, messages
are far from clear for the user !
(cherry picked from commit 5d53634f3634ed377843d37ca5450ffed43ecda8)

src/proto_uxst.c

index b4685d59676acdcd3d6d5f9756135e7a2af3091d..c3fb0ec315834ba3b6d4d38b9883e75107281075 100644 (file)
@@ -113,36 +113,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;
        }
 
@@ -153,12 +153,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;
        }
 
@@ -169,18 +169,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;
        }
 
@@ -190,7 +190,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;
        }