Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 59804 invoked by uid 500); 22 Aug 2002 12:58:43 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 59789 invoked from network); 22 Aug 2002 12:58:43 -0000 Date: Thu, 22 Aug 2002 21:58:39 +0900 (JST) Message-Id: <20020822.215839.15242694.inoue@ariel-networks.com> To: dev@apr.apache.org Subject: [PATCH] handle leak problem (threadproc/win32/thread.c) From: INOUE Seiichiro X-Mailer: Mew version 2.1 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Thu_Aug_22_21:58:39_2002_136)--" Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ----Next_Part(Thu_Aug_22_21:58:39_2002_136)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I have a problem about handle leak related to threads on Windows2000/XP. Excerpt from MSVC help; "Like the Win32 ExitThread API, _endthreadex does not close the thread handle. Therefore, when you use _beginthreadex and _endthreadex, you must close the thread handle by calling the Win32 CloseHandle API." SUZUKI Rintaro wrote the patch. Please review the attachment file. Thanks. - INOUE Seiichiro ----Next_Part(Thu_Aug_22_21:58:39_2002_136)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="thread.c.diff" Index: thread.c =================================================================== RCS file: /home/cvspublic/apr/threadproc/win32/thread.c,v retrieving revision 1.47 diff -u -r1.47 thread.c --- thread.c 19 Mar 2002 17:54:00 -0000 1.47 +++ thread.c 22 Aug 2002 12:56:58 -0000 @@ -138,6 +138,7 @@ #endif if (attr && attr->detach) { CloseHandle((*new)->td); + (*new)->td = NULL; } return APR_SUCCESS; @@ -149,6 +150,9 @@ thd->exitval = retval; apr_pool_destroy(thd->pool); #ifndef _WIN32_WCE + if (thd->td) { + CloseHandle(thd->td); + } _endthreadex(0); #else ExitThread(0); @@ -172,7 +176,8 @@ APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) { - if (CloseHandle(thd->td)) { + if (thd->td && CloseHandle(thd->td)) { + thd->td = NULL; return APR_SUCCESS; } else { ----Next_Part(Thu_Aug_22_21:58:39_2002_136)----