Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 18798:d591a96aed06 legacy-trunk
Instead of accessing ss_family, cast sockaddr_storage to sockaddr and access sa_family.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Mon, 23 Jul 2001 01:30:10 +0000 |
| parents | 4d0ea4c2386d |
| children | 6d9874bb978f |
line wrap: on
line diff
--- a/Modules/socketmodule.c Sat Jul 21 21:16:39 2001 +0000 +++ b/Modules/socketmodule.c Mon Jul 23 01:30:10 2001 +0000 @@ -1894,6 +1894,7 @@ char *name; struct hostent *h; struct sockaddr_storage addr; + struct sockaddr *sa; PyObject *ret; #ifdef HAVE_GETHOSTBYNAME_R struct hostent hp_allocated; @@ -1931,7 +1932,10 @@ h = gethostbyname(name); #endif /* HAVE_GETHOSTBYNAME_R */ Py_END_ALLOW_THREADS - ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), addr.ss_family); + /* Some C libraries would require addr.__ss_family instead of addr.ss_family. + Therefore, we cast the sockaddr_storage into sockaddr to access sa_family. */ + sa = (struct sockaddr*)&addr; + ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), sa->sa_family); #ifdef USE_GETHOSTBYNAME_LOCK PyThread_release_lock(gethostbyname_lock); #endif
