Skip to content

Commit fed2fc4

Browse files
bpo-43895: Remove an unnecessary cache of shared object handles (pythonGH-25487)
* Remove an unnecessary cache of shared object handles.
1 parent 052930f commit fed2fc4

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
An obsolete internal cache of shared object file handles added in 1995 that
2+
attempted, but did not guarantee, that a .so would not be dlopen'ed twice to
3+
work around flaws in mid-1990s posix-ish operating systems has been removed
4+
from dynload_shlib.c.

Python/dynload_shlib.c

-22
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ const char *_PyImport_DynLoadFiletab[] = {
4848
NULL,
4949
};
5050

51-
static struct {
52-
dev_t dev;
53-
ino_t ino;
54-
void *handle;
55-
} handles[128];
56-
static int nhandles = 0;
57-
5851

5952
dl_funcptr
6053
_PyImport_FindSharedFuncptr(const char *prefix,
@@ -77,22 +70,9 @@ _PyImport_FindSharedFuncptr(const char *prefix,
7770
LEAD_UNDERSCORE "%.20s_%.200s", prefix, shortname);
7871

7972
if (fp != NULL) {
80-
int i;
8173
struct _Py_stat_struct status;
8274
if (_Py_fstat(fileno(fp), &status) == -1)
8375
return NULL;
84-
for (i = 0; i < nhandles; i++) {
85-
if (status.st_dev == handles[i].dev &&
86-
status.st_ino == handles[i].ino) {
87-
p = (dl_funcptr) dlsym(handles[i].handle,
88-
funcname);
89-
return p;
90-
}
91-
}
92-
if (nhandles < 128) {
93-
handles[nhandles].dev = status.st_dev;
94-
handles[nhandles].ino = status.st_ino;
95-
}
9676
}
9777

9878
dlopenflags = _PyInterpreterState_GET()->dlopenflags;
@@ -126,8 +106,6 @@ _PyImport_FindSharedFuncptr(const char *prefix,
126106
Py_DECREF(path);
127107
return NULL;
128108
}
129-
if (fp != NULL && nhandles < 128)
130-
handles[nhandles++].handle = handle;
131109
p = (dl_funcptr) dlsym(handle, funcname);
132110
return p;
133111
}

0 commit comments

Comments
 (0)