Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F11021897C for ; Tue, 15 Mar 2016 21:03:12 +0000 (UTC) Received: (qmail 55804 invoked by uid 500); 15 Mar 2016 21:03:12 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 55740 invoked by uid 500); 15 Mar 2016 21:03:12 -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 55730 invoked by uid 99); 15 Mar 2016 21:03:12 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Mar 2016 21:03:12 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id EE37C1A044A for ; Tue, 15 Mar 2016 21:03:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.802 X-Spam-Level: X-Spam-Status: No, score=-0.802 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id m7mQILSGzYwy for ; Tue, 15 Mar 2016 21:03:10 +0000 (UTC) Received: from mail-qk0-f171.google.com (mail-qk0-f171.google.com [209.85.220.171]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id D3CBE5F3F3 for ; Tue, 15 Mar 2016 21:03:09 +0000 (UTC) Received: by mail-qk0-f171.google.com with SMTP id x1so12744435qkc.1 for ; Tue, 15 Mar 2016 14:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-transfer-encoding; bh=dVENQsybW2Gc0hdwedP+/2Xve0Wx707nwBNgdSXwtm8=; b=Jz57cZYiqcz9Wdv5FdWBznuj/FkWDb/CxQXy9nQzDCcNqHytk+zxvmzbmOkk4wz5D5 5ZrByWEhXsyLStrsJchbuAeGwiyEtnvhLMVA3zQC1DNiShMcZ2WXiyXRFk6J6D37N0X/ B6MICvV6sK1j8GUBsKu43hHO1/5cAnDGHkjfAwfAoZg5nGdSfwZaUdC6dolP9S5aOJkC SZywC4dKiW5r3TVxCZ88yV0Pr7tJd+6JHuzylDmUzS8V+KEmas5xnTDNjjogobZzOh0z 9eb2FpGbBMdaH0cfhpQJpVcxOteSiSbvS51S5Uj3Amei9iD0pkc5ciFlBkBpV+Yv1BFM XhfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-transfer-encoding; bh=dVENQsybW2Gc0hdwedP+/2Xve0Wx707nwBNgdSXwtm8=; b=J82AsJoa7ezABa5UTK32NUnKg2QR7GuyOmMTC/a0inX18+xcmSDEHU8bQPZ7jEcJC1 +Q6PwJ7GmfZm5OInrrWN5ikQBSl4XAvo5MgcAfU1MvejrTcgT0uhKHoc5JJ3g9Leyspq c/mlTHZP4wTF0Zn5TU/1BxJaV47WpgrInnLS0c7oWgaz4q8T6+mYR99YZe779ni3BNLY yCZAESBpl9oPyr/wRVs//KcKBioNn7r2SE16IERmeqvIRrP6XoLLx3OMb41UU1kvu5hW UrfDsaprKo5Mcg8r6pEYwz/FWxesXoUAQT5mtIKiH7nIF0ZMvXjGym5FqXVwhmc+pnvU jXkg== X-Gm-Message-State: AD7BkJIq+qULfTy0gU+QgzO3wJRKatIpxwbcWbuG+mrXapOebpIq+YnnfQc/mbrVFhcm0yKVx/TrlvLpsLfHiA== MIME-Version: 1.0 X-Received: by 10.55.73.68 with SMTP id w65mr210273qka.68.1458075783658; Tue, 15 Mar 2016 14:03:03 -0700 (PDT) Received: by 10.55.10.7 with HTTP; Tue, 15 Mar 2016 14:03:03 -0700 (PDT) In-Reply-To: <49F9F117-9C1F-4D44-AB02-9505D7614265@sharp.fm> References: <61123A0F-0B90-4DCD-B995-30E961DDCBF3@sharp.fm> <65C15DDA-BCC2-49F4-B3D7-96B4853F524E@sharp.fm> <9A01C97A-18EF-49B4-ACE9-84C9290ACD1B@sharp.fm> <49F9F117-9C1F-4D44-AB02-9505D7614265@sharp.fm> Date: Tue, 15 Mar 2016 22:03:03 +0100 Message-ID: Subject: Re: Proposed change to mpm_register_socket_callback(): apr_socket_t -> apr_pollfd_t From: Yann Ylavic To: httpd-dev Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Mar 15, 2016 at 8:28 PM, Graham Leggett wrote: > > The trouble with the above is that because of the pool cleanup we now hav= e, pfds[3] needs to live as long as pool p. In your example it does, but th= ere is nothing stopping someone trying to allocate pfds[3] on the stack and= then returning. Later the cleanup is run, and boom - difficult to debug cr= ash or weird behaviour. Was just an example on the possibily to use a plain array for the interface (a stacked one is of course not recommended to register an event callback likely run out of scope). > > With the array you=E2=80=99re guaranteed the memory is allocated from a p= ool, which means the pool cleanup will always be safe. You convinced me, I like your may better now ;) Possibly we could also force each pfd->p to pfds->pool in event_register_poll_callback_ex(). > > What we should also do is drop the apr_pool_t *p parameter and read it fr= om apr_header_array_t=E2=80=99s pool instead. This will be a further check = to stop the caller from doing anything pathological, as we definitely know = the cleanup and the array belong to each other, and our API becomes simpler= still. > > Attached patch does this. +1 Regards, Yann.