Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 34222 invoked from network); 18 Jun 2007 19:51:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jun 2007 19:51:57 -0000 Received: (qmail 45454 invoked by uid 500); 18 Jun 2007 19:51:59 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 45443 invoked by uid 500); 18 Jun 2007 19:51:58 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 45434 invoked by uid 99); 18 Jun 2007 19:51:58 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jun 2007 12:51:58 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of Beau.Croteau@ca.com designates 141.202.248.38 as permitted sender) Received: from [141.202.248.38] (HELO mail12.ca.com) (141.202.248.38) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jun 2007 12:51:53 -0700 Received: from USILMS12.ca.com ([141.202.201.12]) by mail12.ca.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 18 Jun 2007 15:51:32 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Apache Thread Creation/Destroy Problem (mod_ssl problem) Date: Mon, 18 Jun 2007 15:51:31 -0400 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Apache Thread Creation/Destroy Problem (mod_ssl problem) Thread-Index: Aceum/PWC9k6H7kfSqOjggPSfCaCKgAAMVywANEa3yA= References: <20070614162854.0ca901a4@grimnir> <467165B9.9000905@joe-lewis.com> From: "Croteau, Beau" To: X-OriginalArrivalTime: 18 Jun 2007 19:51:32.0023 (UTC) FILETIME=[11A6FC70:01C7B1E2] X-Virus-Checked: Checked by ClamAV on apache.org I've taken mod_gsoap out of it and implemented my own, bare-bones module. The code for the module is this: #include "stdafx.h" #include "helloworld.h" #include "stdafx.h" #if !defined(__GNUC__) || __GNUC__ < 2 || \ (__GNUC__ =3D=3D 2 && __GNUC_MINOR__ < 7) ||\ defined(NEXT) #ifndef __attribute__ #define __attribute__(__x) #endif #endif #include #include #include "winsock2.h" #include "apr_strings.h" #include "apr_fnmatch.h" #include "apr_strings.h" #include "apr_lib.h" #include "apr_pools.h" #define APR_WANT_STRFUNC #include "apr_want.h" #include "httpd.h" #include "http_request.h" #include "http_config.h" #include "http_core.h" #include "http_log.h" #include "http_main.h" #include "http_protocol.h" #include "http_request.h" #include "util_script.h" #include void testThread2(void* input) { printf("Sample module: Another thread being launching - %d\n",GetCurrentThreadId()); return; } void testThread(void* input) { while(1) { printf("Sample module, launching thread.\n"); _beginthread(testThread2,0,NULL); Sleep(5000); } return; } static int helloworld_handler(request_rec *r) { /* First, some housekeeping. */ if (!r->handler || strcasecmp(r->handler, "helloworld") !=3D 0) { /* r->handler wasn't "helloworld", so it's none of our business */ return DECLINED; } if (r->method_number !=3D M_GET) { /* We only accept GET and HEAD requests. * They are identical for the purposes of a content generator * Returning an HTTP error code causes Apache to return an * error page (ErrorDocument) to the client. */ return HTTP_METHOD_NOT_ALLOWED; } /* OK, we're happy with this request, so we'll return the response. */ ap_set_content_type(r, "text/html"); ap_rputs("Hello World! .... etc...starting threads...", r); _beginthread(testThread,0,NULL); /* we return OK to indicate that we have successfully processed * the request. No further processing is required. */ return OK; } static void helloworld_hooks(apr_pool_t *pool) { /* hook helloworld_handler in to Apache */ ap_hook_handler(helloworld_handler, NULL, NULL, APR_HOOK_MIDDLE); } module AP_MODULE_DECLARE_DATA helloworld_module =3D { STANDARD20_MODULE_STUFF, NULL, /* per-directory config creator */ NULL, /* dir config merger */ NULL, /* server config creator */ NULL, /* server config merger */ NULL, /* command table */ helloworld_hooks, /*hooks */ }; Once I hit http://localhost:8080/helloworld in my browser the thread handle leak starts. This is evident by the output: C:\Program Files\Apache Software Foundation\Apache2.2\bin>httpd.exe -X Sample module, launching thread. Sample module: Another thread being launching - 15156 Sample module, launching thread. Sample module: Another thread being launching - 15712 Sample module, launching thread. Sample module: Another thread being launching - 16300 Sample module, launching thread. Sample module: Another thread being launching - 16372 Sample module, launching thread. Sample module: Another thread being launching - 16912 Sample module, launching thread. Sample module: Another thread being launching - 13972 Sample module, launching thread. Sample module: Another thread being launching - 13980 Sample module, launching thread. Sample module: Another thread being launching - 14528 Sample module, launching thread. Sample module: Another thread being launching - 17488 Sample module, launching thread. Sample module: Another thread being launching - 17508 C:\>handle -a -p 13112 | find "15156" 310: Thread httpd.exe(13112): 15156 If I comment out the mod_ssl module: C:\Program Files\Apache Software Foundation\Apache2.2\bin>httpd.exe -X Sample module, launching thread. Sample module: Another thread being launching - 33200 Sample module, launching thread. Sample module: Another thread being launching - 33832 Sample module, launching thread. Sample module: Another thread being launching - 34348 Sample module, launching thread. Sample module: Another thread being launching - 34352 Sample module, launching thread. Sample module: Another thread being launching - 34900 Sample module, launching thread. C:\>handle -a -p 32212 | find "33200" It clearly is 'freed' correctly. Does anybody have any ideas. I don't see any 'hooks' in OpenSSL for thread creation or destruction, but maybe I'm missing something. (Yes, I have used the APR thread functions to no avail as well). I'm really perplexed by the behavior. --Beau -----Original Message----- From: Croteau, Beau [mailto:Beau.Croteau@ca.com]=20 Sent: Thursday, June 14, 2007 11:59 AM To: modules-dev@httpd.apache.org Subject: RE: Apache Thread Creation/Destroy Problem The thread is created inside of the gsoap_handler. Though these threads aren't necessarily mapped to a one to one gsoap_handler call. We have a web service 'startup' function that creates several background threads to do the processing and from there don't necessary have to have the gsoap_handler called again for the thread leak to start happening. --Beau -----Original Message----- From: Joe Lewis [mailto:joe@joe-lewis.com]=20 Sent: Thursday, June 14, 2007 11:59 AM To: modules-dev@httpd.apache.org Subject: Re: Apache Thread Creation/Destroy Problem Croteau, Beau wrote: > I'm sorry, I don't understand the question. > > Mod_gsoap hooks in as such: > static void > gsoap_hooks(apr_pool_t * p) > { > // I think this is the call to make to register a handler for method > calls (GET PUT et. al.). > // We will ask to be last so that the comment has a higher tendency > to > // go at the end. > ap_hook_handler(gsoap_handler, NULL, NULL, APR_HOOK_LAST); > > //Register a handler for post config processing=20 > ap_hook_post_config(gsoap_init, NULL, NULL, APR_HOOK_MIDDLE); > } > =20 [snip] I think we need to know if you create the thread in the gsoap_init function or the gsoap_handler function (not a copy of the register_hooks function, but which hook that register_hooks uses to create the thread). Joe