diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-02-28 21:34:34 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-02-28 21:34:34 (GMT) |
commit | e64ef931d6e4ee800fcd156b28269569d989783c (patch) | |
tree | 2e9b258b1ccfce81c2006f747dfd891308fd3d51 | |
parent | 5e67cded409218e4957c0921cd6b0dca7ba63317 (diff) | |
download | cpython-e64ef931d6e4ee800fcd156b28269569d989783c.zip cpython-e64ef931d6e4ee800fcd156b28269569d989783c.tar.gz cpython-e64ef931d6e4ee800fcd156b28269569d989783c.tar.bz2 |
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.
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Python/thread_nt.h | 15 |
2 files changed, 2 insertions, 14 deletions
@@ -474,6 +474,7 @@ Rickard Westman Truida Wiedijk Gerry Wiener Bryce "Zooko" Wilcox-O'Hearn +Gerald S. Williams Sue Williams Frank Willison Greg V. Wilson diff --git a/Python/thread_nt.h b/Python/thread_nt.h index 0192707..44814c6 100644 --- a/Python/thread_nt.h +++ b/Python/thread_nt.h @@ -1,11 +1,11 @@ /* This code implemented by Dag.Gruneau@elsa.preseco.comm.se */ /* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru */ +/* Eliminated some memory leaks, gsw@agere.com */ #include <windows.h> #include <limits.h> #include <process.h> -#include <Python.h> typedef struct NRMUTEX { LONG owned ; @@ -13,9 +13,6 @@ typedef struct NRMUTEX { HANDLE hevent ; } 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) ; /* Sorry mate, but we haven't got InterlockedCompareExchange in Win95! */ @@ -139,16 +136,10 @@ void FreeNonRecursiveMutex(PNRMUTEX mutex) 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. */ 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; callobj *obj; int id; - PyObject *key, *val; dprintf(("%ld: PyThread_start_new_thread called\n", PyThread_get_thread_ident())); if (!initialized) @@ -203,9 +193,6 @@ long PyThread_start_new_thread(void (*func)(void *), void *arg) /* wait for thread to initialize and retrieve id */ WaitForSingleObject(obj->done, 5000); /* maybe INFINITE instead of 5000? */ CloseHandle((HANDLE)obj->done); - key = PyLong_FromLong(obj->id); - val = PyLong_FromLong((long)rv); - PyDict_SetItem(threads, key, val); id = obj->id; free(obj); return id; |