]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUILD] fix build on Solaris due to recent log changes
authorWilly Tarreau <w@1wt.eu>
Wed, 5 Dec 2007 23:53:51 +0000 (00:53 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Dec 2007 23:53:51 +0000 (00:53 +0100)
Solaris, as well as many other unixes doesn't know about sun_len
for UNIX domain sockets. It does not honnor the __SOCKADDR_COMMON
macro either. After looking at MacOS-X man (which is the same as
BSD man), OpenBSD man, and examples on the net, it appears that
those which support sun_len do not actually use it, or at least
ignore it as long as it's zero. Since all the sockaddr structures
are zeroed prior to being filled, it causes no problem not to set
sun_len, and this fixes build on other platforms.

Another problem on Solaris was that the "sun" name is already
defined as a macro returning a number, so it was necessary to
rename it.

src/log.c
src/standard.c

index fdb3b8c456d87f608ac47dce29b0f61c41d15487..c7ea25c8deba00d64ccceee32685999f8b82e2ab 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -149,7 +149,6 @@ int get_log_facility(const char *fac)
  */
 static inline int logsrv_addrlen(const struct logsrv *logsrv)
 {
-#ifdef __SOCKADDR_COMMON
        switch (logsrv->u.addr.sa_family) {
        case AF_UNIX:
                return sizeof(logsrv->u.un);
@@ -158,16 +157,6 @@ static inline int logsrv_addrlen(const struct logsrv *logsrv)
        default:
                break;
        }
-#else  /* !__SOCKADDR_COMMON */
-       switch (logsrv->u.addr.sa_family) {
-       case AF_UNIX:
-               return logsrv->u.un.sun_len;
-       case AF_INET:
-               return logsrv->u.in.sin_len;
-       default:
-               break;
-       }
-#endif /* !__SOCKADDR_COMMON */
        return -1;
 }
 
index dc09467eaab3565ffef59e89c4f43c649d88769c..93cf1f89e5d9a5eb4bfbab87a0d6cb2e333cd817 100644 (file)
@@ -14,6 +14,8 @@
 #include <netdb.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
+#include <sys/un.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
@@ -83,30 +85,26 @@ const char *limit_r(unsigned long n, char *buffer, int size, const char *alt)
  */
 struct sockaddr_un *str2sun(char *str)
 {
-       static struct sockaddr_un sun;
+       static struct sockaddr_un su;
        int strsz;      /* length included null */
 
-       memset(&sun, 0, sizeof(sun));
+       memset(&su, 0, sizeof(su));
        str = strdup(str);
        if (str == NULL)
                goto out_nofree;
 
        strsz = strlen(str) + 1;
-       if (strsz > sizeof(sun.sun_path)) {
+       if (strsz > sizeof(su.sun_path)) {
                Alert("Socket path '%s' too long (max %d)\n",
-                       str, sizeof(sun.sun_path) - 1);
+                       str, sizeof(su.sun_path) - 1);
                goto out_nofree;
        }
-
-#ifndef __SOCKADDR_COMMON
-       sun.sun_len = sizeof(sun.sun_path);
-#endif  /* !__SOCKADDR_COMMON */
-       sun.sun_family = AF_UNIX;
-       memcpy(sun.sun_path, str, strsz);
+       su.sun_family = AF_UNIX;
+       memcpy(su.sun_path, str, strsz);
 
        free(str);
  out_nofree:
-       return &sun;
+       return &su;
 }
 
 /*
@@ -141,7 +139,7 @@ const char *invalid_char(const char *name)
                return name;
 
        while (*name) {
-               if (!isalnum(*name) && *name != '.' && *name != ':' &&
+               if (!isalnum((int)*name) && *name != '.' && *name != ':' &&
                    *name != '_' && *name != '-')
                        return name;
                name++;
@@ -184,9 +182,6 @@ struct sockaddr_in *str2sa(char *str)
                else
                        sa.sin_addr = *(struct in_addr *) *(he->h_addr_list);
        }
-#ifndef __SOCKADDR_COMMON
-       sa.sin_len = sizeof(sa);
-#endif  /* !__SOCKADDR_COMMON */
        sa.sin_port   = htons(port);
        sa.sin_family = AF_INET;