Return-Path: X-Original-To: apmail-subversion-dev-archive@minotaur.apache.org Delivered-To: apmail-subversion-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4545918AE8 for ; Tue, 9 Feb 2016 18:19:07 +0000 (UTC) Received: (qmail 79133 invoked by uid 500); 9 Feb 2016 18:19:07 -0000 Delivered-To: apmail-subversion-dev-archive@subversion.apache.org Received: (qmail 79075 invoked by uid 500); 9 Feb 2016 18:19:07 -0000 Mailing-List: contact dev-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@subversion.apache.org Received: (qmail 79059 invoked by uid 99); 9 Feb 2016 18:19:06 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Feb 2016 18:19:06 +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 449CD1A00F0 for ; Tue, 9 Feb 2016 18:19:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.821 X-Spam-Level: X-Spam-Status: No, score=-0.821 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=wandisco.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id LGMKf26HZUps for ; Tue, 9 Feb 2016 18:19:04 +0000 (UTC) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 049E220CB7 for ; Tue, 9 Feb 2016 18:19:03 +0000 (UTC) Received: by mail-wm0-f49.google.com with SMTP id p63so34710597wmp.1 for ; Tue, 09 Feb 2016 10:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wandisco.com; s=gapps; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=OdcSaWClQNHI2OUHesOhqnbp5dyXCvKoGxKyW8Ehb2c=; b=RlmnN8S3D1hDvb5HGQBfObIsFL5bcb69OmZcVXjwdH81QCLr8iQdaMWYOYWmMRrl4J 0jkDSJtxIBFniU2xYNLRQJ35purlewt6vPcnB7zIxDzNRhkOVtECvi9L1jPmMwOOvtxM NknIwXBncNR/+93E7qURcYeHIoYzt1GtiruNc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type :content-transfer-encoding; bh=OdcSaWClQNHI2OUHesOhqnbp5dyXCvKoGxKyW8Ehb2c=; b=MQL5Mxwa8+qmzahm2OoyfpVXD22Ng/3C1kfTDx0olJcxq3bGwgsVPNB3whQsEengzo geqGF87Tod6AJQpjG9PdzfEeE0+6tvs84XhZ9nXoMUraN/0mvikhWo0AfCllYmtZSLO3 5ISg2Puy2hVg1RGF1F2hTjkMG9e71RKP81hY1VT3RRBEXS8k3R7YteWIbT6Wgv+AVyqV zu+67MxQjpin+kXCdgIa8dMhXgVG129h9K7qgwg0Qqm44l5iwptoCJ0ADoG3sSwo63RT Zcz1fVSC1TtB9rtKM5gPweJ4ef4EXcw396R4+0dBOZZGzfCkMWdFM5b3hAXd7CPJbigl 7qQQ== X-Gm-Message-State: AG10YORFOe8aewXnq7U7v5EuevwF3Qzwsm+pcUMoxjDgiOfyUYW2Fei4tgkutUg109NgPPA+ X-Received: by 10.28.131.134 with SMTP id f128mr6643149wmd.41.1455041943686; Tue, 09 Feb 2016 10:19:03 -0800 (PST) Received: from localhost (cpc81211-farn9-2-0-cust890.6-2.cable.virginm.net. [86.22.207.123]) by smtp.gmail.com with ESMTPSA id gt7sm35922652wjc.1.2016.02.09.10.19.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Feb 2016 10:19:02 -0800 (PST) From: Philip Martin To: Daniel Shahaf Cc: dev@subversion.apache.org Subject: Moving cancellation support to libsvn_subr References: <20160129185522.A2F813A0249@svn01-us-west.apache.org> <20160130074708.GA30257@tarsus.local2> <87h9hsaf27.fsf@wandisco.com> <87d1sgad97.fsf__33268.2802960791$1454325642$gmane$org@wandisco.com> <20160207002204.GA13224@tarsus.local2> <87r3gncx0e.fsf@wandisco.com> <20160209032347.GA27845@tarsus.local2> Date: Tue, 09 Feb 2016 18:19:02 +0000 In-Reply-To: <20160209032347.GA27845@tarsus.local2> (Daniel Shahaf's message of "Tue, 09 Feb 2016 03:23:47 +0000") Message-ID: <87y4at927d.fsf_-_@wandisco.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Daniel Shahaf writes: > This fixes the race I mentioned, but I think we have another problem > here: signum_cancelled is accessed by the signal handler so it must be > of type 'static volatile sig_atomic_t' (C89 =C2=A74.7.1.1)... but I don't > think anything guarantees that signal numbers are representable as > a sig_atomic_t. On Linux/amd64 and FreeBSD they are, but that need not > be the case everywhere. > > If we can't assume sig_atomic_t is at least as large as an int, I think > we have to use the following roundabout method: I did something similar in r1729422. This code keeps growing and I'm thinking of moving both the signal handler and cancellation handler to libsvn_subr. We need some storage for the volatiles and using pool memory implies a limited lifetime that interacts badly with the signal handlers so I'm thinking of using static storage in the library. Something like: /* Setup signal handlers and return a cancellation handler. */ svn_cancel_func_t svn_cmdline__setup_cancellation_handler(); /* Return a signal that triggered cancellation or zero if no such signal. */ int svn_cmdline__get_cancelled_signum(); and the application would do: int main() { apr_pool_t *pool; ... SVN_ERR(svn_client_create_context2(&ctx, ..., pool)); ... ctx->cancel_func =3D svn_cmdline__setup_cancellation_handler(); ... svn_pool_destroy(pool); ... #ifndef WIN32 { int signum =3D svn_cmdline__get_cancelled_signum(); if (signum) kill(getpid(), signum); } #endif return exit_code; } --=20 Philip Martin WANdisco