From patchwork Sat Nov 20 20:03:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Morris X-Patchwork-Id: 1986 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [2a01:4f9:c010:3052::1] by patchwork.archlinux.org with IMAP (fetchmail-6.4.23) for (single-drop); Sat, 20 Nov 2021 20:03:51 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id b85lO6ZUmWGXlwgAK+/4rw (envelope-from ) for ; Sat, 20 Nov 2021 20:03:50 +0000 Received: from lists.archlinux.org (lists.archlinux.org [95.217.236.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id 68B55AA1156; Sat, 20 Nov 2021 20:03:49 +0000 (UTC) Received: from lists.archlinux.org (localhost [IPv6:::1]) by lists.archlinux.org (Postfix) with ESMTP id 0E21E9D1910; Sat, 20 Nov 2021 20:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.archlinux.org; s=dkim-rsa; t=1637438629; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=u7EoAyjcYreKZwvJnxgbeyMN9Dcd6GL5tgx0JQa9RV4=; b=TR9Lym9v0GYDdOLkNUWWxi3e/OgDBkDZ1clmD3EROn6tg3Gu09x40ScCj0iVmWZk/jRcFY z11KSJ6c69ujPz6YxqD/6HMRwIFBpV6ifMZO2nmfeMfyS5CTr/0W2vBchchGJKhF794VNS Kuw0m6aRoszzzGFNYYo2We5ziFG4bq83+V7CdFcbNqCiMjthq+YfdvtN1aeWtoCHo0Sh+u 2HM5JHeHwfxr3qmK9lkDIwgQITfuEf5vgxaCzNAD/j7J5IHIsM9kMGV7PkBEzxlSddWB3a /LK4qQKKTsx4ruo4iccYnJH+2CLW6rs2Z/vaiBeqesuABRpcPEpZup1FRMY4+VaiaHwQAO cfsLJhdS97ITdpRZVm8fuNcceX7tJKGvIpZ/mwoEdcjEIspERUz/mKDfI98Iq3oY4nvHmV +QLvlHQ1Oe7OhTgGcAdJIHqol2D5hrUo5lkP3M40kBT1KhLUb5qy3gk/rtOiODE7ejSvaW s+HvqlErubEXNSX2Ku4gce5nlTD/4WFnq85Tf7u+Zvi7SNpAShdpMQe2UQWXjh4m+nfnAH ubsNcsRaez6mpjej6KJUS0aN4FG8N9ehnxbZ4pQxtOLb1r+rTCnlFHpmAQlKelMTsJu7dD h2PDEALU8QYhRflFFeFwZ3IOdpzLWPjNcCto4WiKy+UQ3f79UrLZs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lists.archlinux.org; s=dkim-ed25519; t=1637438629; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=u7EoAyjcYreKZwvJnxgbeyMN9Dcd6GL5tgx0JQa9RV4=; b=d8wuPngvUHzvEZ9WjrpdF9jFA12KkTSX/9y0qfHWIVnAOAvdQRDJO/7Jpu3gKhJnN7jSTF OCwAJ2uo44R4AtAw== X-Original-To: pacman-dev@lists.archlinux.org Delivered-To: pacman-dev@lists.archlinux.org Received: from mail.0cost.org (mail.0cost.org [45.79.226.90]) by lists.archlinux.org (Postfix) with ESMTPS id 4A8D79D1900 for ; Sat, 20 Nov 2021 20:03:46 +0000 (UTC) Received: by mail.0cost.org (Postfix, from userid 1001) id 559135FF22; Sat, 20 Nov 2021 20:03:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mail X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.4 Received: from volcano.local.net (unknown [IPv6:2001:470:1f05:597:2e4d:54ff:fed5:b29c]) by mail.0cost.org (Postfix) with ESMTPSA id 138635FF1F; Sat, 20 Nov 2021 20:03:43 +0000 (UTC) To: pacman-dev@lists.archlinux.org Cc: Kevin Morris Subject: [PATCH v2] fix: release transaction before releasing handle Date: Sat, 20 Nov 2021 12:03:20 -0800 Message-Id: <20211120200320.542060-1-kevr@0cost.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211120050939.53411-1-kevr@0cost.org> References: <20211120050939.53411-1-kevr@0cost.org> MIME-Version: 1.0 X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.35 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Kevin Morris via pacman-dev From: Kevin Morris Reply-To: Kevin Morris Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" Authentication-Results: mail.archlinux.org; dkim=pass header.d=lists.archlinux.org header.s=dkim-rsa header.b=TR9Lym9v; dkim=pass header.d=lists.archlinux.org header.s=dkim-ed25519 header.b=d8wuPngv; dmarc=pass (policy=none) header.from=archlinux.org; spf=pass (mail.archlinux.org: domain of pacman-dev-bounces@lists.archlinux.org designates 95.217.236.249 as permitted sender) smtp.mailfrom=pacman-dev-bounces@lists.archlinux.org X-Rspamd-Queue-Id: 68B55AA1156 X-Spamd-Result: default: False [-7.41 / 15.00]; REPLY(-4.00)[]; DWL_DNSWL_MED(-2.00)[archlinux.org:dkim]; DMARC_POLICY_ALLOW(-0.50)[archlinux.org,none]; R_MISSING_CHARSET(0.50)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; R_DKIM_ALLOW(-0.20)[lists.archlinux.org:s=dkim-rsa,lists.archlinux.org:s=dkim-ed25519]; RCVD_IN_DNSWL_MED(-0.20)[95.217.236.249:from]; MAILLIST(-0.20)[mailman]; R_SPF_ALLOW(-0.20)[+ip4:95.217.236.249]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; HAS_REPLYTO(0.00)[kevr@0cost.org]; PREVIOUSLY_DELIVERED(0.00)[pacman-dev@lists.archlinux.org]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:95.217.0.0/16, country:DE]; DKIM_TRACE(0.00)[lists.archlinux.org:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_NEQ_ENVFROM(0.00)[pacman-dev@lists.archlinux.org,pacman-dev-bounces@lists.archlinux.org]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM(-0.00)[-0.995]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org If a transaction exists, release it if possible. If `alpm_trans_release` errors out (returns a non-zero), return a -1 in `alpm_release`. This patch addresses the following issue observed in `pyalpm`: https://gitlab.archlinux.org/archlinux/pyalpm/-/issues/25, where `pyalpm` ends up raising twice due to an unexpected failure during handle release, while a transaction is locked. This is a modified version of https://patchwork.archlinux.org/project/pacman/patch/20200119191833.581492-1-morganamilo@archlinux.org/ and is a derivation of his (Morganamilo's) work. Signed-off-by: Kevin Morris --- lib/libalpm/alpm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 6708e202..47d02fea 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -100,6 +100,10 @@ int SYMEXPORT alpm_release(alpm_handle_t *myhandle) CHECK_HANDLE(myhandle, return -1); + if (myhandle->trans != NULL && alpm_trans_release(myhandle)) { + return -1; + } + /* close local database */ db = myhandle->db_local; if(db) {