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 763D99121F for ; Wed, 3 Apr 2024 13:01:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 43E9816568 for ; Wed, 3 Apr 2024 13:01:13 +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 for ; Wed, 3 Apr 2024 13:01:12 +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 550D9446CF for ; Wed, 3 Apr 2024 13:01:12 +0200 (CEST) Message-ID: Date: Wed, 3 Apr 2024 13:01:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox Backup Server development discussion , =?UTF-8?Q?Fabian_Gr=C3=BCnbichler?= References: <20240328123707.336951-1-c.ebner@proxmox.com> <20240328123707.336951-7-c.ebner@proxmox.com> <1712136715.t3s03j6zyy.astroid@yuna.none> Content-Language: en-US, de-DE From: Christian Ebner In-Reply-To: <1712136715.t3s03j6zyy.astroid@yuna.none> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 Subject: Re: [pbs-devel] [PATCH v3 pxar 06/58] encoder: move to stack based state tracking 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: Wed, 03 Apr 2024 11:01:43 -0000 On 4/3/24 11:54, Fabian Grünbichler wrote: > > should we still have some sort of checks here? e.g., when dropping an > encoder, how should self.finished and self.state look like? IIUC, then a > dropped encoder should have an empty state and be finished (i.e., > `close()` has been called on it). > > or is this simply not relevant anymore because we only create one and > then drop it at the end (but should we then have a similar mechanism for > EncoderState?) The encoder should now be consumed with the `close` call, which takes ownership of the encoder and drops it afterwards, so all the state checks should happen there. Previously, the encoder finish consumed the per-directory level encoder object, passing possible errors up to the parent implementation, which is not possible now since there is only one encoder instance. I did not want to panic here as the checks should be done in the close now, so the Drop implementation was removed. Not sure what to check in a Drop implementation the EncoderState. What did you have in mind for that? Note that errors get propagated to the parent state in the encoder finish calls now. >> + fn output_state(&mut self) -> io::Result<(&mut T, &mut EncoderState)> { >> + Ok(( >> + self.output.as_mut(), >> + self.state >> + .last_mut() >> + .ok_or_else(|| io_format_err!("encoder state stack underflow"))?, >> + )) >> + } >> + > > we could have another helper here that also returns the Option<&mut T> > for payload_output (while not used as often, it might still be a good > idea for readability): Okay, yes I can add that.