[Python-checkins] CVS: python/dist/src/Python thread_nt.h,2.20,2.20.10.1
Michael Hudson
mwh@users.sourceforge.net
Tue, 05 Mar 2002 05:56:26 -0800
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv19738
Modified Files:
Tag: release22-maint
thread_nt.h
Log Message:
backport tim_one's checkin of
revision 2.22 of thread_nt.h
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.
Index: thread_nt.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_nt.h,v
retrieving revision 2.20
retrieving revision 2.20.10.1
diff -C2 -d -r2.20 -r2.20.10.1
*** thread_nt.h 16 Oct 2001 21:50:04 -0000 2.20
--- thread_nt.h 5 Mar 2002 13:56:23 -0000 2.20.10.1
***************
*** 2,10 ****
/* This code implemented by Dag.Gruneau@elsa.preseco.comm.se */
/* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru */
#include <windows.h>
#include <limits.h>
#include <process.h>
- #include <Python.h>
typedef struct NRMUTEX {
--- 2,10 ----
/* 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>
typedef struct NRMUTEX {
***************
*** 14,20 ****
} 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) ;
--- 14,17 ----
***************
*** 140,153 ****
/*
- * 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();
}
--- 137,144 ----
***************
*** 183,187 ****
callobj *obj;
int id;
- PyObject *key, *val;
dprintf(("%ld: PyThread_start_new_thread called\n", PyThread_get_thread_ident()));
--- 174,177 ----
***************
*** 204,210 ****
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);
--- 194,197 ----