Skip to content

Commit

Permalink
Fixed a SEGV error when using nanomsg on CentOS5/RHEL5
Browse files Browse the repository at this point in the history
Older versions of glibc have a problem with getaddrinfo_a and the size of
stack it allocates for the thread that performs the lookup. This causes a
process built with nanomsg to crash when it needs to do a DNS lookup.

This fixes this issue by allowing the use of getaddrinfo_a to be disabled
at configuration time by specifying '--disable-getaddrinfo_a'.
  • Loading branch information
yoink00 authored and djc committed Jan 26, 2015
1 parent 6db4e7d commit d907795
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,20 @@ AC_CHECK_FUNCS([accept4], [
AC_DEFINE([NN_HAVE_ACCEPT4])
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
])

AC_SEARCH_LIBS([getaddrinfo_a], [anl], [
AC_DEFINE([NN_HAVE_GETADDRINFO_A])
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
])
# Allow the use of getaddrinfo_a to be disabled.
AC_ARG_ENABLE([getaddrinfo_a],
AS_HELP_STRING([--enable-getaddrinfo_a], [Use getaddrinfo_a if available [default=yes]])
)
AS_IF([test x"$enable_getaddrinfo_a" == "xno"], [
AC_DEFINE([NN_DISABLE_GETADDRINFO_A])
])


AC_SEARCH_LIBS([socketpair], [], [
AC_DEFINE([NN_HAVE_SOCKETPAIR])
])
Expand Down
2 changes: 1 addition & 1 deletion src/transports/utils/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int nn_dns_check_hostname (const char *name, size_t namelen)
}
}

#if defined NN_HAVE_GETADDRINFO_A
#if defined NN_HAVE_GETADDRINFO_A && !defined NN_DISABLE_GETADDRINFO_A
#include "dns_getaddrinfo_a.inc"
#else
#include "dns_getaddrinfo.inc"
Expand Down
2 changes: 1 addition & 1 deletion src/transports/utils/dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int nn_dns_check_hostname (const char *name, size_t namelen);
#define NN_DNS_DONE 1
#define NN_DNS_STOPPED 2

#if defined NN_HAVE_GETADDRINFO_A
#if defined NN_HAVE_GETADDRINFO_A && !defined NN_DISABLE_GETADDRINFO_A
#include "dns_getaddrinfo_a.h"
#else
#include "dns_getaddrinfo.h"
Expand Down

0 comments on commit d907795

Please sign in to comment.