8000 gh-103092: Isolate socket by erlend-aasland · Pull Request #103094 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-103092: Isolate socket #103094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Apr 9, 2023
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4a7c6d9
Establish global state
erlend-aasland Mar 11, 2023
220a0aa
Add sock_type to state
erlend-aasland Mar 12, 2023
94ca00c
Add exceptions to state
erlend-aasland Mar 12, 2023
fc9cdce
Add accept4_works to state
erlend-aasland Mar 12, 2023
29b4d1c
Add sock_cloexec_works to state
erlend-aasland Mar 12, 2023
93a2b62
Add defaulttimeout to state
erlend-aasland Mar 12, 2023
4164f96
Refactor: replace state query with param in set_herror()
erlend-aasland Mar 12, 2023
dc740d1
Refactor: replace state query with param in set_gaierror()
erlend-aasland Mar 12, 2023
abf00c3
Refactor: replace state query with param in new_sockobject()
erlend-aasland Mar 12, 2023
9c1c9c6
Refactor: replace state query with param in init_sockobject()
erlend-aasland Mar 12, 2023
82c00c4
Refactor: replace state query with param in gethost_common()
erlend-aasland Mar 12, 2023
72e69e3
Refactor: replace state query with param in sock_get_api()
erlend-aasland Mar 12, 2023
274c412
Refactor: replace state query with param in setipaddr()
erlend-aasland Mar 12, 2023
d839af0
Add state pointer to PySocketSockObject
erlend-aasland Mar 12, 2023
13d14da
Use sock pointer from sock type context where applicable
erlend-aasland Mar 12, 2023
b4edf64
Multi-phase init
erlend-aasland Mar 12, 2023
c51a696
Remove unneeded forward decl
erlend-aasland Mar 30, 2023
d8e448f
Add test
erlend-aasland Mar 30, 2023
4332571
fixup dealloc
erlend-aasland Mar 30, 2023
6a00c54
Add NEWS
erlend-aasland Apr 3, 2023
e5027c2
Style: remove unneeded parens
erlend-aasland Apr 4, 2023
8000
98d1566
Pull in main
erlend-aasland Apr 4, 2023
e5827e7
Sync with main
erlend-aasland Apr 8, 2023
2019a93
Simplify ADD_EXC macro further
erlend-aasland Apr 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor: replace state query with param in gethost_common()
  • Loading branch information
erlend-aasland committed Mar 28, 2023
commit 82c00c4e3e4cdf6f035ca72b2b61c4ab6e41e3b7
10 changes: 6 additions & 4 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5715,7 +5715,8 @@ sock_decode_hostname(const char *name)
/* Convenience function common to gethostbyname_ex and gethostbyaddr */

static PyObject *
gethost_common(struct hostent *h, struct sockaddr *addr, size_t alen, int af)
gethost_common(socket_state *state, struct hostent *h, struct sockaddr *addr,
size_t alen, int af)
{
char **pch;
PyObject *rtn_tuple = (PyObject *)NULL;
Expand All @@ -5726,7 +5727,6 @@ gethost_common(struct hostent *h, struct sockaddr *addr, size_t alen, int af)

if (h == NULL) {
/* Let's get real error message to return */
socket_state *state = GLOBAL_STATE();
set_herror(state, h_errno);
return NULL;
}
Expand Down Expand Up @@ -5900,8 +5900,9 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args)
addr.ss_family.
Therefore, we cast the sockaddr_storage into sockaddr to
access sa_family. */
socket_state *state = GLOBAL_STATE();
sa = SAS2SA(&addr);
ret = gethost_common(h, SAS2SA(&addr), sizeof(addr),
ret = gethost_common(state, h, SAS2SA(&addr), sizeof(addr),
sa->sa_family);
#ifdef USE_GETHOSTBYNAME_LOCK
PyThread_release_lock(netdb_lock);
Expand Down Expand Up @@ -5999,7 +6000,8 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
h = gethostbyaddr(ap, al, af);
#endif /* HAVE_GETHOSTBYNAME_R */
Py_END_ALLOW_THREADS
ret = gethost_common(h, SAS2SA(&addr), sizeof(addr), af);
socket_state *state = GLOBAL_STATE();
ret = gethost_common(state, h, SAS2SA(&addr), sizeof(addr), af);
#ifdef USE_GETHOSTBYNAME_LOCK
PyThread_release_lock(netdb_lock);
#endif
Expand Down
0