From: Alexander Gavrilov <angavrilov@gmail.com>
To: Christian Jaeger <christian@jaeger.mine.nu>
Cc: git@vger.kernel.org
Subject: [PATCH (GITK BUGFIX)] gitk: Allow safely calling nukefile from a run queue handler.
Date: Sat, 9 Aug 2008 14:41:50 +0400 [thread overview]
Message-ID: <200808091441.50444.angavrilov@gmail.com> (raw)
In-Reply-To: <217ad8e755d8d51e2ec0f06b4bffa0864976f7e4.1218277122.git.christian@jaeger.mine.nu>
Originally dorunq assumed that the queue entry remained first
in the queue after the script eval, and blindly removed it.
However, if the handler calls nukefile, it may not be the
case anymore, and a random queue entry gets dropped instead.
This patch makes dorunq remove the entry before calling the
script, and adds a global variable to allow other functions
to determine if they are called from within a dorunq handler.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
On Saturday 09 August 2008 14:04:43 Christian Jaeger wrote:
> gitk would not show diffs (or trees when choosing tree view) about
> half of the times it is started, it would only show the commit
> messages. Sometimes it took dozens of times to get it to show a diff
> again, then show it again the next 3 starts, then the next 2 starts
> not, then the next 2 starts would show it again, and so on.
I think I guessed the cause of this bug: if two or more files
become ready for reading at once, and the first one in the queue
calls nukefile on itself, the next one will get silently dropped from
the queue. If the second one was a diff pipe, the diff system gets
wedged until gitk is restarted.
Please test if this patch fixes it.
-- Alexander
gitk | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/gitk b/gitk
index b523c98..18d000c 100755
--- a/gitk
+++ b/gitk
@@ -22,11 +22,11 @@ proc gitdir {} {
# run before X event handlers, so reading from a fast source can
# make the GUI completely unresponsive.
proc run args {
- global isonrunq runq
+ global isonrunq runq currunq
set script $args
if {[info exists isonrunq($script)]} return
- if {$runq eq {}} {
+ if {$runq eq {} && ![info exists currunq]} {
after idle dorunq
}
lappend runq [list {} $script]
@@ -38,10 +38,10 @@ proc filerun {fd script} {
}
proc filereadable {fd script} {
- global runq
+ global runq currunq
fileevent $fd readable {}
- if {$runq eq {}} {
+ if {$runq eq {} && ![info exists currunq]} {
after idle dorunq
}
lappend runq [list $fd $script]
@@ -60,17 +60,19 @@ proc nukefile {fd} {
}
proc dorunq {} {
- global isonrunq runq
+ global isonrunq runq currunq
set tstart [clock clicks -milliseconds]
set t0 $tstart
while {[llength $runq] > 0} {
set fd [lindex $runq 0 0]
set script [lindex $runq 0 1]
+ set currunq [lindex $runq 0]
+ set runq [lrange $runq 1 end]
set repeat [eval $script]
+ unset currunq
set t1 [clock clicks -milliseconds]
set t [expr {$t1 - $t0}]
- set runq [lrange $runq 1 end]
if {$repeat ne {} && $repeat} {
if {$fd eq {} || $repeat == 2} {
# script returns 1 if it wants to be readded
--
1.6.0.rc2
next prev parent reply other threads:[~2008-08-09 10:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-08 14:41 [BUG/PATCH] Revert "gitk: Arrange to kill diff-files & diff-index on quit" Christian Jaeger
2008-08-09 9:13 ` Alexander Gavrilov
2008-08-09 10:04 ` [PATCH] gitk: make diff and tree display work reliably again Christian Jaeger
2008-08-09 10:41 ` Alexander Gavrilov [this message]
2008-08-09 11:24 ` [PATCH (GITK BUGFIX)] gitk: Allow safely calling nukefile from a run queue handler Christian Jaeger
2008-08-11 1:02 ` Christian Jaeger
2008-08-11 20:44 ` Junio C Hamano
2008-08-11 0:15 ` Paul Mackerras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200808091441.50444.angavrilov@gmail.com \
--to=angavrilov@gmail.com \
--cc=christian@jaeger.mine.nu \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).