Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 75297 invoked from network); 14 Dec 2009 09:00:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Dec 2009 09:00:49 -0000 Received: (qmail 352 invoked by uid 500); 14 Dec 2009 09:00:48 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 271 invoked by uid 500); 14 Dec 2009 09:00:48 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 262 invoked by uid 99); 14 Dec 2009 09:00:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Dec 2009 09:00:48 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of joseph.yx.chen@gmail.com designates 209.85.223.185 as permitted sender) Received: from [209.85.223.185] (HELO mail-iw0-f185.google.com) (209.85.223.185) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Dec 2009 09:00:40 +0000 Received: by iwn15 with SMTP id 15so1735416iwn.10 for ; Mon, 14 Dec 2009 01:00:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=DtIc3G0GKyZuC9CAz+F6bmNMRyNNQwYTesZ06fCKvjI=; b=KzPX3vuTpe8AiFjz9loOykAvZFyhlduYBdgLm74j65Yv4TJ57NyGv/45+DPtyq3Fhe MaAGg17Xb/pawh/lAaisS1GX/iquZduMA+4o2zM7bdID4/vPDeWaRI1Qb0DdlVE66ZoD r5wGxQyU5NZjCaXQ97RhXrcnoS4CB7cKVaR6o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=ZwRX3h3CGJ3/vKnFa2hiL13VsIWCDhYOr5rpCkQ7c596CSt5pAfRDQlcnZkMmCqHYe 1gNQoLgrtlZ9oZIyXbJsCAw5hdC23UVq1QYJoAE7Ihd76LC9CatWOFJiEjmXiuOUSmwk Rt5uGb82Bp0GgejDq8V3FEIpAyJYYxWKX2J/o= MIME-Version: 1.0 Received: by 10.231.125.28 with SMTP id w28mr1290288ibr.50.1260781219346; Mon, 14 Dec 2009 01:00:19 -0800 (PST) In-Reply-To: <4B25F441.3010109@apache.org> References: <1d76cd4f0912140003y21053c7ckcb70a747f4ecdf75@mail.gmail.com> <4B25F441.3010109@apache.org> Date: Mon, 14 Dec 2009 02:00:19 -0700 Message-ID: <1d76cd4f0912140100u1113ffb6w3f8d8bad38dc5006@mail.gmail.com> Subject: Re: Function for child_init_hook being called more than one times? From: joseph Chen To: dev@httpd.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org On Mon, Dec 14, 2009 at 1:16 AM, Ruediger Pluem wrote: > This hook is called for every child spawned by the main process. > So if you have multiple client processes (which is very likely) it is > called multiple times. > > Maybe some background information could enable people to provide better help. Thanks Ruediger for your quick reply. The background info is that I need to have httpd to spawn a new thread to run my own routine where I will have socket interface to read data from a port and then to modify some gloable variables. Hope you can see my programming logic from following code (to create a thread to run my routine that just writes log message to my own file): void* APR_THREAD_FUNC my_listener(apr_thread_t *thread, void *data) { my_server_cfg_t *cfg = (my_server_cfg_t *) data; int i; for (i = 0;; i++) { apr_sleep(10); my_log_to_file( "%s:%s:%d:thread i = %d\n", i); } return NULL; } static void my_child_init(apr_pool_t *p, server_rec *s) { my_server_cfg_t *cfg; cfg = ap_get_module_config(s->module_config, &my_module); /* start up ingestor receiver */ /* create a thread */ apr_thread_create(&cfg->listener_thread, NULL, my_listener, (void *)cfg, p); apr_pool_cleanup_register(p, s, my_child_exit, my_child_exit); } And within the "my_register_hooks()", my module code calls: ap_hook_child_init (my_child_init, NULL, NULL, APR_HOOK_MIDDLE); When looking at my own log file, I can see the thead was created too many times. Thanks, --Joe