From modules-dev-return-5291-archive-asf-public=cust-asf.ponee.io@httpd.apache.org Mon Dec 14 12:39:01 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-he-de.apache.org (mxout1-he-de.apache.org [95.216.194.37]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id 478E4180634 for ; Mon, 14 Dec 2020 13:39:01 +0100 (CET) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-he-de.apache.org (ASF Mail Server at mxout1-he-de.apache.org) with SMTP id E6CC167223 for ; Mon, 14 Dec 2020 12:38:58 +0000 (UTC) Received: (qmail 88092 invoked by uid 500); 14 Dec 2020 12:38:57 -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 88080 invoked by uid 99); 14 Dec 2020 12:38:57 -0000 Received: from spamproc1-he-fi.apache.org (HELO spamproc1-he-fi.apache.org) (95.217.134.168) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Dec 2020 12:38:57 +0000 Received: from localhost (localhost [127.0.0.1]) by spamproc1-he-fi.apache.org (ASF Mail Server at spamproc1-he-fi.apache.org) with ESMTP id 9C333C03FC for ; Mon, 14 Dec 2020 12:38:56 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamproc1-he-fi.apache.org X-Spam-Flag: NO X-Spam-Score: -0.201 X-Spam-Level: X-Spam-Status: No, score=-0.201 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamproc1-he-fi.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-he-de.apache.org ([116.203.227.195]) by localhost (spamproc1-he-fi.apache.org [95.217.134.168]) (amavisd-new, port 10024) with ESMTP id 4ism384PLFOd for ; Mon, 14 Dec 2020 12:38:56 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::d34; helo=mail-io1-xd34.google.com; envelope-from=ylavic.dev@gmail.com; receiver= Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with ESMTPS id D90A17F9EE for ; Mon, 14 Dec 2020 12:38:55 +0000 (UTC) Received: by mail-io1-xd34.google.com with SMTP id z136so16638543iof.3 for ; Mon, 14 Dec 2020 04:38:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=D2tLoLvPyL8ouWdUETRMpb+r7Rgplf/wkspxpJ+hbwk=; b=nUQBifaU6o/fOecHUBWUMJNCJ//BIdKLz9dTNq6c9lAzq19Vpq/Zee/zmhfn/nTFWS t14xgBRt2GPnRs95TF3nGNhc/0w2BagqwmFJixDHdOcMmbsWF5O/dosbFHw8rLkmPxa6 1+kFYTvZTwP3ZCD0aSJ7bYS2zrdwU5bXDEpVlTZPPLDKUBwtY6woYqDWfUhdW+asnrtG ZiNHiMyfTm6+Ij10LXedwHoTyT0IO+25r4j3qTuiiZLFmDxfxw6ElnVWai3B3Wjlv7lL ngJByxWX3Z4a7FXwPHg1qOK3heVHrg29/M74bYtmQe+DTz8gJlucsXgeGkWxFJRFGX/w myFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=D2tLoLvPyL8ouWdUETRMpb+r7Rgplf/wkspxpJ+hbwk=; b=KkbUyr2fjROl5NwI2leou3ys48G17i0yfbCJ0X02Aez2OQ8ZV1yy2buWSKRTZiXbGh 01Dkjgw8so+WJKnlOoFCBLTAK+e6srJVgNfxTCq3M6lQdc/LmJhTJNbambnMGmJUTQk+ 4aBi+9lLvsiZEoqFql/o8V1PC93R7VGSZfNIQUCGMu64wg9MjmBt4n/oXqucsaro43kQ 1f4BGDGQBQ+L3jLuhSrts7WO63Jgah9Et9hAXAjXQ+c9E8uq0c8+k9WqoaPNwzh9Amux kuZu1733tDwm8+RwTsjh48UeIuhligTuEHeE8tbqM5FWfOi9KDkjyzy2lKy7mK6iQNEi d5uA== X-Gm-Message-State: AOAM532wOOXra/gkCmmEijr4MH2+o1dDKz3z8tSfDhIXA+KVDJE6l1e1 FKx01vTJnb0YYZWaDu4LREgZVVtXi2tsqGu++GSUm1n6BlHLJQ== X-Google-Smtp-Source: ABdhPJzMVcDDzP62Zmh3bJ7jANwEuwJGpAy3A64jm4eH0q7vlkdmxUw9FB+QMauhE21Pwvok8ZKAgp7JK16Ye4cPHOE= X-Received: by 2002:a6b:7206:: with SMTP id n6mr32257115ioc.118.1607949534133; Mon, 14 Dec 2020 04:38:54 -0800 (PST) MIME-Version: 1.0 References: <20201214121055.6f58c08e@teclador.wfnet> In-Reply-To: <20201214121055.6f58c08e@teclador.wfnet> From: Yann Ylavic Date: Mon, 14 Dec 2020 13:38:43 +0100 Message-ID: Subject: Re: child_init hook: Main vs. MPM processes To: httpd-mods Content-Type: text/plain; charset="UTF-8" Hi Florian, On Mon, Dec 14, 2020 at 12:11 PM Florian Wagner wrote: > > is there a simple way to detect in a child_init hook if the current > process is also the main server process (the one that runs the > pre_config hook). It depends on the MPMs your module is targeting. For unix MPMs (which fork() children processes) the config hooks are called only by the parent process, but others like MPM winnt do call them (plus child_init) in the child process too (there is only one child on winnt, and threads to handle the connections/requests) > > At least for debug mode (-X commandline switch) both pre_config and > child_init are being both run for that single process and there's some > stuff I need to do in my module that only ever should be run in child > processes. > > I could store the main process pid in get pre_config hook and compare > it with getpid() result in the child_init but maybe there's a more > elegant solution? With unix MPMs, pre/post_config and child_init hooks run in the same process only happen for ONE_PROCESS mode (-X), so the check could be ap_exists_config_define("ONE_PROCESS") to determine that. With MPM winnt there is no inheritance/fork() of the parent resources on Windows so I don't know if your do-that-in-the-child-only design applies there anyway. The child process can be identified with "getenv("AP_PARENT_PID") != NULL" if you need it, but as said above it does not mean that config hooks are not run.. Regards; Yann.