From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 726AC70D43 for ; Tue, 7 Sep 2021 09:50:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 671BC19356 for ; Tue, 7 Sep 2021 09:50:30 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 9894A19348 for ; Tue, 7 Sep 2021 09:50:29 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 59ECB445E7 for ; Tue, 7 Sep 2021 09:50:23 +0200 (CEST) Date: Tue, 7 Sep 2021 09:49:37 +0200 (CEST) From: Dietmar Maurer To: Proxmox Backup Server development discussion , Wolfgang Bumiller , Dominik Csapak Message-ID: <1069826666.2878.1631000977842@webmail.proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.5-Rev21 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.686 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lib.rs, proxmox.com] Subject: Re: [pbs-devel] applied: [PATCH proxmox-backup v2 1/2] pbs-config: add 'create_mocked_lock' helper X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2021 07:50:30 -0000 I really do not like this solution :-( > On 09/07/2021 9:05 AM Wolfgang Bumiller wrote: > > > applied both patches > > On Mon, Sep 06, 2021 at 05:00:25PM +0200, Dominik Csapak wrote: > > by making the field an option and making it None in the mocked case > > this function is only intended for testing and hidden from the docs > > > > Signed-off-by: Dominik Csapak > > --- > > changes from v1: > > * mark function unsafe, so that it is even more clear that this is not > > intended for 'normal' code > > pbs-config/src/lib.rs | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/pbs-config/src/lib.rs b/pbs-config/src/lib.rs > > index 29811164..bd5430a3 100644 > > --- a/pbs-config/src/lib.rs > > +++ b/pbs-config/src/lib.rs > > @@ -18,7 +18,13 @@ pub fn backup_group() -> Result { > > pbs_tools::sys::query_group(BACKUP_GROUP_NAME)? > > .ok_or_else(|| format_err!("Unable to lookup '{}' group.", BACKUP_GROUP_NAME)) > > } > > -pub struct BackupLockGuard(std::fs::File); > > +pub struct BackupLockGuard(Option); > > + > > +#[doc(hidden)] > > +/// Note: do not use for production code, this is only intended for tests > > +pub unsafe fn create_mocked_lock() -> BackupLockGuard { > > + BackupLockGuard(None) > > +} > > > > /// Open or create a lock file owned by user "backup" and lock it. > > /// > > @@ -41,7 +47,7 @@ pub fn open_backup_lockfile>( > > let timeout = timeout.unwrap_or(std::time::Duration::new(10, 0)); > > > > let file = proxmox::tools::fs::open_file_locked(&path, timeout, exclusive, options)?; > > - Ok(BackupLockGuard(file)) > > + Ok(BackupLockGuard(Some(file))) > > } > > > > /// Atomically write data to file owned by "root:backup" with permission "0640" > > -- > > 2.30.2 > > > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel