From patchwork Fri Dec 8 14:53:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13485477 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="YcUsJNC7"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="hr4BhDW8" Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DA704C2E for ; Fri, 8 Dec 2023 06:53:06 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 1A5DC320077A; Fri, 8 Dec 2023 09:53:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 08 Dec 2023 09:53:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1702047184; x=1702133584; bh=Uz BFYxHGgBVtEJGlUELGUayA7oNlbWLe/nYuyIkfrfU=; b=YcUsJNC7DGRPM5d8Xb oQbcXGr53VX91tZJxHqtZvCsulMkt0qMYKIUlfrWf1frke0PAtInofWdyQMY01gK Yn3gF+Yh95ZGlJeKR6mI5LG8m1K3kWiQeA1x5fUVdj+GUTOuRQ8dgN6HUTmZqm+M UcGWCb9f0bnRkRWtCX5wvBmSB8WWmQgYTYl2JsF5IZ0jcS1EyNW0LLIU1Xhl8f8C cACBHqfnNx1KiHoLmHGBOgtR+wkn/Bv5ryj0L73JuDmjVbCKIJDsAcdRgLgtxiTj v33yaj8wLd2Xy7Y5+Zzd+nW18eQZMH4iil+xJEkuGeMgPaIehzZvS5bAjaqPIvPH uYzA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1702047184; x=1702133584; bh=UzBFYxHGgBVtE JGlUELGUayA7oNlbWLe/nYuyIkfrfU=; b=hr4BhDW8WlH8LhlrXbc0BKmNiCZ8I t67MzhEzUE3dQi/jNd79bhIV6hJF5soHV4oA9OpQsJRK/1+s+bz0OS8TDYvAGDOg eLBty6UshvsRHj1ncQOOvLN71mC8vprBDqp7MWpWodjqCIBBNDLWF7vT8zf8IOqX 4s+Of5Ns0nFamnIQrTXgiFhLCW9lJZ4pEWulO0vmZDl7L8lscn20qp2zXv3aTC83 8+CzdzjxxeBCK1a7FCnTtjUdG73Y1DlPFDUxTkmb8+GwOJOAPa9C/fnMAJyxi74F jwjKGN3fSLkTaPza1gBGAjKfQFxSWBwMy43rv9PQZ5lIFc6+Ia9FXFkzQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudekiedgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 8 Dec 2023 09:53:03 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 3cb134f2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 8 Dec 2023 14:51:33 +0000 (UTC) Date: Fri, 8 Dec 2023 15:53:02 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Jonathan Nieder Subject: [PATCH v2 02/11] reftable: handle interrupted reads Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: There are calls to pread(3P) and read(3P) where we don't properly handle interrupts. Convert them to use `pread_in_full()` and `read_in_full()`, respectively. Signed-off-by: Patrick Steinhardt --- reftable/blocksource.c | 2 +- reftable/stack.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/reftable/blocksource.c b/reftable/blocksource.c index 8331b34e82..a1ea304429 100644 --- a/reftable/blocksource.c +++ b/reftable/blocksource.c @@ -109,7 +109,7 @@ static int file_read_block(void *v, struct reftable_block *dest, uint64_t off, struct file_block_source *b = v; assert(off + size <= b->size); dest->data = reftable_malloc(size); - if (pread(b->fd, dest->data, size, off) != size) + if (pread_in_full(b->fd, dest->data, size, off) != size) return -1; dest->len = size; return size; diff --git a/reftable/stack.c b/reftable/stack.c index ddbdf1b9c8..ed108a929b 100644 --- a/reftable/stack.c +++ b/reftable/stack.c @@ -92,7 +92,7 @@ static int fd_read_lines(int fd, char ***namesp) } buf = reftable_malloc(size + 1); - if (read(fd, buf, size) != size) { + if (read_in_full(fd, buf, size) != size) { err = REFTABLE_IO_ERROR; goto done; }