[Python-checkins] bpo-43895: Remove an unnecessary cache of shared object handles (GH-25487)
gpshead
webhook-mailer at python.org
Wed Jul 7 19:26:15 EDT 2021
https://github.com/python/cpython/commit/fed2fc4443235fa9669b73817827fd6da88e3417
commit: fed2fc4443235fa9669b73817827fd6da88e3417
branch: main
author: Ian Henriksen <insertinterestingnamehere at gmail.com>
committer: gpshead <greg at krypto.org>
date: 2021-07-07T16:26:06-07:00
summary:
bpo-43895: Remove an unnecessary cache of shared object handles (GH-25487)
* Remove an unnecessary cache of shared object handles.
files:
A Misc/NEWS.d/next/Core and Builtins/2021-07-07-16-05-35.bpo-43895.JFjR0-.rst
M Python/dynload_shlib.c
diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-07-07-16-05-35.bpo-43895.JFjR0-.rst b/Misc/NEWS.d/next/Core and Builtins/2021-07-07-16-05-35.bpo-43895.JFjR0-.rst
new file mode 100644
index 0000000000000..49deb48fa4358
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2021-07-07-16-05-35.bpo-43895.JFjR0-.rst
@@ -0,0 +1,4 @@
+An obsolete internal cache of shared object file handles added in 1995 that
+attempted, but did not guarantee, that a .so would not be dlopen'ed twice to
+work around flaws in mid-1990s posix-ish operating systems has been removed
+from dynload_shlib.c.
diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c
index 23828898d35a5..3c5fd83df584d 100644
--- a/Python/dynload_shlib.c
+++ b/Python/dynload_shlib.c
@@ -48,13 +48,6 @@ const char *_PyImport_DynLoadFiletab[] = {
NULL,
};
-static struct {
- dev_t dev;
- ino_t ino;
- void *handle;
-} handles[128];
-static int nhandles = 0;
-
dl_funcptr
_PyImport_FindSharedFuncptr(const char *prefix,
@@ -77,22 +70,9 @@ _PyImport_FindSharedFuncptr(const char *prefix,
LEAD_UNDERSCORE "%.20s_%.200s", prefix, shortname);
if (fp != NULL) {
- int i;
struct _Py_stat_struct status;
if (_Py_fstat(fileno(fp), &status) == -1)
return NULL;
- for (i = 0; i < nhandles; i++) {
- if (status.st_dev == handles[i].dev &&
- status.st_ino == handles[i].ino) {
- p = (dl_funcptr) dlsym(handles[i].handle,
- funcname);
- return p;
- }
- }
- if (nhandles < 128) {
- handles[nhandles].dev = status.st_dev;
- handles[nhandles].ino = status.st_ino;
- }
}
dlopenflags = _PyInterpreterState_GET()->dlopenflags;
@@ -126,8 +106,6 @@ _PyImport_FindSharedFuncptr(const char *prefix,
Py_DECREF(path);
return NULL;
}
- if (fp != NULL && nhandles < 128)
- handles[nhandles++].handle = handle;
p = (dl_funcptr) dlsym(handle, funcname);
return p;
}
More information about the Python-checkins
mailing list