diff options
author | Guido van Rossum <guido@python.org> | 1999-03-24 17:24:33 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-03-24 17:24:33 (GMT) |
commit | e7de2061b405d93cd5fa55c553d6cfc51bfb853e (patch) | |
tree | c701799fb66bce45edb0bc36ab59ccf4f3481be1 /Modules/socketmodule.c | |
parent | 7b6c71f5a438647618d095b85728bf4d0c011353 (diff) | |
download | cpython-e7de2061b405d93cd5fa55c553d6cfc51bfb853e.zip cpython-e7de2061b405d93cd5fa55c553d6cfc51bfb853e.tar.gz cpython-e7de2061b405d93cd5fa55c553d6cfc51bfb853e.tar.bz2 |
Implement two suggestions by Jonathan Giddy: (1) in AIX, clear the
data struct before calling gethostby{name,addr}_r(); (2) ignore the
3/5/6 args determinations made by the configure script and switch on
platform identifiers instead:
AIX, OSF have 3 args
Sun, SGI have 5 args
Linux has 6 args
On all other platforms, undef HAVE_GETHOSTBYNAME_R altogether.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 8415d90..d37a218 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -87,6 +87,22 @@ Socket methods: #include "Python.h" +#undef HAVE_GETHOSTBYNAME_R_3_ARG +#undef HAVE_GETHOSTBYNAME_R_5_ARG +#undef HAVE_GETHOSTBYNAME_R_6_ARG + +#ifdef HAVE_GETHOSTBYNAME_R +#if defined(_AIX) || defined(__osf__) +#define HAVE_GETHOSTBYNAME_R_3_ARG +#elif defined(__sun__) || defined(__sgi) +#define HAVE_GETHOSTBYNAME_R_5_ARG +#elif defined(linux) +#define HAVE_GETHOSTBYNAME_R_6_ARG +#else +#undef HAVE_GETHOSTBYNAME_R +#endif +#endif + #if !defined(HAVE_GETHOSTBYNAME_R) && defined(WITH_THREAD) && !defined(MS_WINDOWS) #define USE_GETHOSTBYNAME_LOCK #endif @@ -373,6 +389,7 @@ BUILD_FUNC_DEF_2(setipaddr, char*,name, struct sockaddr_in *,addr_ret) #elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) hp = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop); #else /* HAVE_GETHOSTBYNAME_R_3_ARG */ + memset((void *) &data, '\0', sizeof(data)); result = gethostbyname_r(name, &hp_allocated, &data); hp = (result != 0) ? NULL : &hp_allocated; #endif @@ -1451,6 +1468,7 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyname_ex,PyObject *,self, PyObject *,args) #elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop); #else /* HAVE_GETHOSTBYNAME_R_3_ARG */ + memset((void *) &data, '\0', sizeof(data)); result = gethostbyname_r(name, &hp_allocated, &data); h = (result != 0) ? NULL : &hp_allocated; #endif @@ -1516,6 +1534,7 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyaddr,PyObject *,self, PyObject *, args) AF_INET, &hp_allocated, buf, buf_len, &errnop); #else /* HAVE_GETHOSTBYNAME_R_3_ARG */ + memset((void *) &data, '\0', sizeof(data)); result = gethostbyaddr_r((char *)&addr.sin_addr, sizeof(addr.sin_addr), AF_INET, &hp_allocated, &data); |