git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 18:10 UTC

[PATCH 2/3] gitk: remove closed file descriptors from $blobdifffd

From
Markus Hitter <mah@jump-ing.de>
Date
Nov 7, 2016, 19:01 UTC
Message-ID
<8e1c5923-d2a6-bc77-97ab-3f154b41d2ea@jump-ing.de>
In-Reply-To
<e09a5309-351d-d246-d272-f527f50ad444@jump-ing.de>
From 0a463fcd977dc9558835c373e24a095e35ca3c82 Mon Sep 17 00:00:00 2001
From: Markus Hitter <mah@jump-ing.de>
Date: Mon, 7 Nov 2016 16:01:17 +0100
Subject: [PATCH 2/3] gitk: remove closed file descriptors from $blobdifffd
One shouldn't have descriptors of already closed files around.

The first idea to deal with this (previously) ever growing array was to remove it entirely, but it's needed to detect start of a new diff with ths old diff not yet done. This happens when a user clicks on the same commit in the commit list repeatedly without delay.

Signed-off-by: Markus Hitter <mah@jump-ing.de>
---
 gitk | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/gitk b/gitk
index 8654e29..518a4ce 100755
--- a/gitk
+++ b/gitk
@@ -8069,7 +8069,11 @@ proc getblobdiffline {bdf ids} {
     $ctext conf -state normal
     while {[incr nr] <= 1000 && [gets $bdf line] >= 0} {
 	if {$ids != $diffids || $bdf != $blobdifffd($ids)} {
+	    # Older diff read. Abort it.
 	    catch {close $bdf}
+	    if {$ids != $diffids} {
+		array unset blobdifffd $ids
+	    }
 	    return 0
 	}
 	parseblobdiffline $ids $line
@@ -8078,6 +8082,7 @@ proc getblobdiffline {bdf ids} {
     blobdiffmaybeseehere [eof $bdf]
     if {[eof $bdf]} {
 	catch {close $bdf}
+	array unset blobdifffd $ids
 	return 0
     }
     return [expr {$nr >= 1000? 2: 1}]
-- 
2.9.3
Previous: Markus HitterNext: Markus Hitter
Message 3 of 9 in “gitk: memory consumption improvements”
  1. 0/3 gitk: memory consumption improvementsMarkus Hitter, Nov 7, 2016
  2. 1/3 gitk: turn off undo manager in the text widgetMarkus Hitter, Nov 7, 2016
  3. 2/3 gitk: remove closed file descriptors from $blobdifffdMarkus Hitter, Nov 7, 2016
  4. 3/3 gitk: clear array 'commitinfo' on reloadMarkus Hitter, Nov 7, 2016
  5. Jacob KellerNov 7, 2016
  6. Junio C HamanoNov 8, 2016
  7. Markus HitterNov 9, 2016
  8. Junio C HamanoNov 9, 2016
  9. Paul MackerrasDec 12, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.