You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2014/04/08 23:53:27 UTC
git commit: THRIFT-2454: c_glib: There is no gethostbyname_r() in
some OS
Repository: thrift
Updated Branches:
refs/heads/master 5829a2c64 -> bea3144a4
THRIFT-2454: c_glib: There is no gethostbyname_r() in some OS
Patch: Jin-wook Jeong
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/bea3144a
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/bea3144a
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/bea3144a
Branch: refs/heads/master
Commit: bea3144a456a635c7a2e84c92277c5ad27f892d6
Parents: 5829a2c
Author: Roger Meier <ro...@apache.org>
Authored: Tue Apr 8 23:52:01 2014 +0200
Committer: Roger Meier <ro...@apache.org>
Committed: Tue Apr 8 23:52:01 2014 +0200
----------------------------------------------------------------------
configure.ac | 1 +
lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/bea3144a/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 483c283..f4d1869 100755
--- a/configure.ac
+++ b/configure.ac
@@ -530,6 +530,7 @@ AC_CHECK_FUNCS([strtoul])
AC_CHECK_FUNCS([bzero])
AC_CHECK_FUNCS([ftruncate])
AC_CHECK_FUNCS([gethostbyname])
+AC_CHECK_FUNCS([gethostbyname_r])
AC_CHECK_FUNCS([gettimeofday])
AC_CHECK_FUNCS([memmove])
AC_CHECK_FUNCS([memset])
http://git-wip-us.apache.org/repos/asf/thrift/blob/bea3144a/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c
index a371ace..68eb21c 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c
@@ -54,16 +54,24 @@ thrift_socket_is_open (ThriftTransport *transport)
gboolean
thrift_socket_open (ThriftTransport *transport, GError **error)
{
- struct hostent he, *hp = NULL;
+ struct hostent *hp = NULL;
struct sockaddr_in pin;
int err;
+#if defined(HAVE_GETHOSTBYNAME_R)
+ struct hostent he;
char buf[1024];
+#endif
ThriftSocket *tsocket = THRIFT_SOCKET (transport);
g_return_val_if_fail (tsocket->sd == 0, FALSE);
/* lookup the destination host */
- if (gethostbyname_r(tsocket->hostname, &he, buf, 1024, &hp, &err) != 0 || hp == NULL) {
+#if defined(HAVE_GETHOSTBYNAME_R)
+ if (gethostbyname_r (tsocket->hostname, &he, buf, 1024, &hp, &err) != 0 || hp == NULL)
+#else
+ if ((hp = gethostbyname (tsocket->hostname)) == NULL && (err = h_errno))
+#endif
+ {
/* host lookup failed, bail out with an error */
g_set_error (error, THRIFT_TRANSPORT_ERROR, THRIFT_TRANSPORT_ERROR_HOST,
"host lookup failed for %s:%d - %s",