From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116715 invoked by alias); 13 Jun 2018 01:36:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 116697 invoked by uid 89); 13 Jun 2018 01:36:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:8.14.7, our X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Jun 2018 01:36:33 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w5D1aOpC008413 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jun 2018 21:36:29 -0400 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 15E141E529; Tue, 12 Jun 2018 21:36:21 -0400 (EDT) Subject: Re: [PATCH RFC 4/5] Introduce scoped_mmapped_file From: Simon Marchi To: Tom Tromey Cc: Simon Marchi , gdb-patches@sourceware.org References: <1525901216-15031-1-git-send-email-simon.marchi@ericsson.com> <1525901216-15031-5-git-send-email-simon.marchi@ericsson.com> <87y3grz0px.fsf@tromey.com> <1601635db4edc8926dfcf2a82db65c3e@polymtl.ca> Message-ID: <66729562-48db-21f4-2443-f7208d0d13b4@polymtl.ca> Date: Wed, 13 Jun 2018 01:36:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1601635db4edc8926dfcf2a82db65c3e@polymtl.ca> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 13 Jun 2018 01:36:24 +0000 X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00324.txt.bz2 On 2018-05-10 05:10 PM, Simon Marchi wrote: > On 2018-05-10 16:59, Tom Tromey wrote: >>>>>>> "Simon" == Simon Marchi writes: >> >> Simon> + void reset (int new_fd) >> Simon> + { >> Simon> + destroy (); >> Simon> + >> Simon> + m_fd = new_fd; >> Simon> + } >> >> I was wondering if this should only destroy() when new_fd!=m_fd. >> That way self-resetting would not cause a bug. > > It probably should, indeed. I looked into this a bit more, and I think I'll leave it like this. This is how unique_ptr works (at least libstdc++'s and libc++'s implementations of it), and that's how our other scoped_* implementations work (scoped_mmap amd ref_ptr). Simon