from memcached errors (aka convert ints to strings)
* Fixed type in MEMCACHED_HOST_LOOKUP_FAILURE
* Fixed bug where hostname might not be null terminated
+ * Moved to using gethostbyname_r() on Linux to solve thread safety issue
0.9 Thu Nov 15 07:44:00 PST 2007
* fix for when no servers are definied.
AC_C_CONST
AC_TYPE_SIZE_T
-AC_CHECK_HEADERS(limits.h syslimits.h)
+AC_CHECK_FUNC(gethostbyname_r, AC_DEFINE([HAVE_GETHOSTBYNAME_R], [], [Looking for gethostbyname_r]))
AC_OUTPUT(Makefile src/Makefile tests/Makefile docs/Makefile lib/Makefile include/Makefile support/Makefile support/libmemcached.pc support/libmemcached.spec)
static memcached_return set_hostinfo(memcached_server_st *server)
{
struct hostent *h;
-
+#ifdef HAVE_GETHOSTBYNAME_R
+ struct hostent h_static;
+ char buffer[SMALL_STRING_LEN];
+ int tmp_error;
+
+ if (gethostbyname_r(server->hostname,
+ &h_static, buffer, SMALL_STRING_LEN,
+ &h, &tmp_error))
+ {
+ WATCHPOINT_STRING(server->hostname);
+ WATCHPOINT_STRING(hstrerror(tmp_error));
+ return MEMCACHED_HOST_LOOKUP_FAILURE;
+ }
+#else
if ((h= gethostbyname(server->hostname)) == NULL)
{
WATCHPOINT_STRING(server->hostname);
WATCHPOINT_STRING(hstrerror(h_errno));
return MEMCACHED_HOST_LOOKUP_FAILURE;
}
+#endif
server->servAddr.sin_family= h->h_addrtype;
memcpy((char *) &server->servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
+
server->servAddr.sin_port = htons(server->port);
return MEMCACHED_SUCCESS;