diff options
Diffstat (limited to '')
-rw-r--r-- | jnlib/ChangeLog | 5 | ||||
-rw-r--r-- | jnlib/logging.c | 4 | ||||
-rw-r--r-- | jnlib/mischelp.h | 32 |
3 files changed, 38 insertions, 3 deletions
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog index 8c12f5fc5..b9984235c 100644 --- a/jnlib/ChangeLog +++ b/jnlib/ChangeLog @@ -1,3 +1,8 @@ +2009-05-19 Werner Koch <[email protected]> + + * mischelp.h: Define PF_LOCAL, AF_LOCAL and SUN_LEN if requested. + * logging.c (fun_writer): Use SUN_LEN to fix a Mac OS X freeze. + 2009-03-25 Werner Koch <[email protected]> * logging.c (fun_closer): Never close fd 2. diff --git a/jnlib/logging.c b/jnlib/logging.c index 40b58aeb9..6267dc11c 100644 --- a/jnlib/logging.c +++ b/jnlib/logging.c @@ -39,6 +39,7 @@ #define JNLIB_NEED_LOG_LOGV 1 +#define JNLIB_NEED_AFLOCAL 1 #include "libjnlib-config.h" #include "logging.h" @@ -152,8 +153,7 @@ fun_writer (void *cookie_arg, const char *buffer, my_funopen_hook_size_t size) addr.sun_family = PF_LOCAL; strncpy (addr.sun_path, cookie->name, sizeof (addr.sun_path)-1); addr.sun_path[sizeof (addr.sun_path)-1] = 0; - addrlen = (offsetof (struct sockaddr_un, sun_path) - + strlen (addr.sun_path) + 1); + addrlen = SUN_LEN (&addr); if (connect (cookie->fd, (struct sockaddr *) &addr, addrlen) == -1) { diff --git a/jnlib/mischelp.h b/jnlib/mischelp.h index 2f003e1ce..6bf7a9174 100644 --- a/jnlib/mischelp.h +++ b/jnlib/mischelp.h @@ -1,6 +1,6 @@ /* mischelp.h - Miscellaneous helper macros and functions * Copyright (C) 1999, 2000, 2001, 2002, 2003, - * 2006, 2007 Free Software Foundation, Inc. + * 2006, 2007, 2009 Free Software Foundation, Inc. * * This file is part of JNLIB. * @@ -60,5 +60,35 @@ time_t timegm (struct tm *tm); #define wipememory(_ptr,_len) wipememory2(_ptr,0,_len) +/* Include hacks which are mainly required for Slowaris. */ +#if defined(JNLIB_NEED_AFLOCAL) && !defined(HAVE_W32_SYSTEM) +#include <sys/socket.h> +#include <sys/un.h> + +#ifndef PF_LOCAL +# ifdef PF_UNIX +# define PF_LOCAL PF_UNIX +# else +# define PF_LOCAL AF_UNIX +# endif +#endif /*PF_LOCAL*/ +#ifndef AF_LOCAL +# define AF_LOCAL AF_UNIX +#endif /*AF_UNIX*/ + +/* We used to avoid this macro in GnuPG and inlined the AF_LOCAL name + length computation directly with the little twist of adding 1 extra + byte. It seems that this was needed once on an old HP/UX box and + there are also rumours that 4.3 Reno and DEC systems need it. This + one-off buglet did not harm any current system until it came to Mac + OS X where the kernel (as of May 2009) exhibited a strange bug: The + systems basically froze in the connect call if the passed name + contained an invalid directory part. Ignore the old Unices. */ +#ifndef SUN_LEN +# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \ + + strlen ((ptr)->sun_path)) +#endif /*SUN_LEN*/ +#endif /*JNLIB_NEED_AFLOCAL && !HAVE_W32_SYSTEM*/ + #endif /*LIBJNLIB_MISCHELP_H*/ |