SF patch 522961: Leak in Python/thread_nt.h, from Gerald S. Williams.

A file-static "threads" dict mapped thread IDs to Windows handles, but
was never referenced, and entries never got removed.  This gets rid of
the YAGNI-dict entirely.
Bugfix candidate.
This commit is contained in:
Tim Peters 2002-02-28 21:34:34 +00:00
parent 5e67cded40
commit e64ef931d6
2 changed files with 2 additions and 14 deletions

View File

@ -474,6 +474,7 @@ Rickard Westman
Truida Wiedijk Truida Wiedijk
Gerry Wiener Gerry Wiener
Bryce "Zooko" Wilcox-O'Hearn Bryce "Zooko" Wilcox-O'Hearn
Gerald S. Williams
Sue Williams Sue Williams
Frank Willison Frank Willison
Greg V. Wilson Greg V. Wilson

View File

@ -1,11 +1,11 @@
/* This code implemented by Dag.Gruneau@elsa.preseco.comm.se */ /* This code implemented by Dag.Gruneau@elsa.preseco.comm.se */
/* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru */ /* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru */
/* Eliminated some memory leaks, gsw@agere.com */
#include <windows.h> #include <windows.h>
#include <limits.h> #include <limits.h>
#include <process.h> #include <process.h>
#include <Python.h>
typedef struct NRMUTEX { typedef struct NRMUTEX {
LONG owned ; LONG owned ;
@ -13,9 +13,6 @@ typedef struct NRMUTEX {
HANDLE hevent ; HANDLE hevent ;
} NRMUTEX, *PNRMUTEX ; } NRMUTEX, *PNRMUTEX ;
/* dictionary to correlate thread ids with the handle needed to terminate them*/
static PyObject *threads = NULL;
typedef PVOID WINAPI interlocked_cmp_xchg_t(PVOID *dest, PVOID exc, PVOID comperand) ; typedef PVOID WINAPI interlocked_cmp_xchg_t(PVOID *dest, PVOID exc, PVOID comperand) ;
/* Sorry mate, but we haven't got InterlockedCompareExchange in Win95! */ /* Sorry mate, but we haven't got InterlockedCompareExchange in Win95! */
@ -138,17 +135,11 @@ void FreeNonRecursiveMutex(PNRMUTEX mutex)
long PyThread_get_thread_ident(void); long PyThread_get_thread_ident(void);
/*
* Change all headers to pure ANSI as no one will use K&R style on an
* NT
*/
/* /*
* Initialization of the C package, should not be needed. * Initialization of the C package, should not be needed.
*/ */
static void PyThread__init_thread(void) static void PyThread__init_thread(void)
{ {
threads = PyDict_New();
} }
/* /*
@ -182,7 +173,6 @@ long PyThread_start_new_thread(void (*func)(void *), void *arg)
int success = 0; int success = 0;
callobj *obj; callobj *obj;
int id; int id;
PyObject *key, *val;
dprintf(("%ld: PyThread_start_new_thread called\n", PyThread_get_thread_ident())); dprintf(("%ld: PyThread_start_new_thread called\n", PyThread_get_thread_ident()));
if (!initialized) if (!initialized)
@ -203,9 +193,6 @@ long PyThread_start_new_thread(void (*func)(void *), void *arg)
/* wait for thread to initialize and retrieve id */ /* wait for thread to initialize and retrieve id */
WaitForSingleObject(obj->done, 5000); /* maybe INFINITE instead of 5000? */ WaitForSingleObject(obj->done, 5000); /* maybe INFINITE instead of 5000? */
CloseHandle((HANDLE)obj->done); CloseHandle((HANDLE)obj->done);
key = PyLong_FromLong(obj->id);
val = PyLong_FromLong((long)rv);
PyDict_SetItem(threads, key, val);
id = obj->id; id = obj->id;
free(obj); free(obj);
return id; return id;