From patchwork Fri Nov 22 08:37:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Hommey X-Patchwork-Id: 11257501 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9941F913 for ; Fri, 22 Nov 2019 08:54:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8390920714 for ; Fri, 22 Nov 2019 08:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727139AbfKVIye (ORCPT ); Fri, 22 Nov 2019 03:54:34 -0500 Received: from ns332406.ip-37-187-123.eu ([37.187.123.207]:34194 "EHLO glandium.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbfKVIye (ORCPT ); Fri, 22 Nov 2019 03:54:34 -0500 Received: from glandium by mitsuha.glandium.org with local (Exim 4.92.3) (envelope-from ) id 1iY4R6-0007cq-IG; Fri, 22 Nov 2019 17:37:04 +0900 From: Mike Hommey To: git@vger.kernel.org Cc: gitster@pobox.com Subject: [PATCH 1/2] revision: clear the topo-walk flags in reset_revision_walk Date: Fri, 22 Nov 2019 17:37:03 +0900 Message-Id: <20191122083704.29267-1-mh@glandium.org> X-Mailer: git-send-email 2.24.0.dirty MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Not doing so can lead to wrong topo-walks when using the revision walk API consecutively. Signed-off-by: Mike Hommey --- revision.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) As mentioned in 20191108025007.bphr7ynvskeoe6tb@glandium.org, it feels like maybe TOPO_WALK_EXPLORED and TOPO_WALK_INDEGREE should be in ALL_REV_FLAGS too? diff --git a/revision.c b/revision.c index 0e39b2b8a5..765a56ae33 100644 --- a/revision.c +++ b/revision.c @@ -3098,7 +3098,7 @@ static void set_children(struct rev_info *revs) void reset_revision_walk(void) { - clear_object_flags(SEEN | ADDED | SHOWN); + clear_object_flags(SEEN | ADDED | SHOWN | TOPO_WALK_EXPLORED | TOPO_WALK_INDEGREE); } static int mark_uninteresting(const struct object_id *oid, From patchwork Fri Nov 22 08:37:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Hommey X-Patchwork-Id: 11257499 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94C0B913 for ; Fri, 22 Nov 2019 08:54:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7EC9E20714 for ; Fri, 22 Nov 2019 08:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727130AbfKVIya (ORCPT ); Fri, 22 Nov 2019 03:54:30 -0500 Received: from ns332406.ip-37-187-123.eu ([37.187.123.207]:34192 "EHLO glandium.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbfKVIya (ORCPT ); Fri, 22 Nov 2019 03:54:30 -0500 X-Greylist: delayed 1041 seconds by postgrey-1.27 at vger.kernel.org; Fri, 22 Nov 2019 03:54:29 EST Received: from glandium by mitsuha.glandium.org with local (Exim 4.92.3) (envelope-from ) id 1iY4R6-0007cs-Iu; Fri, 22 Nov 2019 17:37:04 +0900 From: Mike Hommey To: git@vger.kernel.org Cc: gitster@pobox.com Subject: [PATCH 2/2] revision: free topo_walk_info before creating a new one in init_topo_walk Date: Fri, 22 Nov 2019 17:37:04 +0900 Message-Id: <20191122083704.29267-2-mh@glandium.org> X-Mailer: git-send-email 2.24.0.dirty In-Reply-To: <20191122083704.29267-1-mh@glandium.org> References: <20191122083704.29267-1-mh@glandium.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org init_topo_walk doesn't reuse an existing topo_walk_info, and currently leaks the one that might exist on the current rev_info if it was already used for a topo walk beforehand. Signed-off-by: Mike Hommey --- revision.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) The FREE_AND_NULL() -> xmalloc dance could be avoided, but I figured the function ought to be reused in the future to clear the rev_info. I was thinking to add a call in reset_revision_walk instead, but reset_revision_walk doesn't take an argument at all currently. diff --git a/revision.c b/revision.c index 765a56ae33..7e23c5ed08 100644 --- a/revision.c +++ b/revision.c @@ -3211,10 +3211,26 @@ static void compute_indegrees_to_depth(struct rev_info *revs, indegree_walk_step(revs); } +static void reset_topo_walk(struct rev_info *revs) +{ + struct topo_walk_info *info = revs->topo_walk_info; + + clear_prio_queue(&info->explore_queue); + clear_prio_queue(&info->indegree_queue); + clear_prio_queue(&info->topo_queue); + clear_indegree_slab(&info->indegree); + clear_author_date_slab(&info->author_date); + + FREE_AND_NULL(revs->topo_walk_info); +} + static void init_topo_walk(struct rev_info *revs) { struct topo_walk_info *info; struct commit_list *list; + if (revs->topo_walk_info) + reset_topo_walk(revs); + revs->topo_walk_info = xmalloc(sizeof(struct topo_walk_info)); info = revs->topo_walk_info; memset(info, 0, sizeof(struct topo_walk_info));