From: Max Kirillov <max@max630.net>
To: Paul Mackerras <paulus@samba.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v4 2/2] gitk: synchronize config write
Date: Mon, 2 Mar 2015 22:43:54 +0200 [thread overview]
Message-ID: <20150302204354.GB7622@wheezy.local> (raw)
In-Reply-To: <20150302001050.GC24862@iris.ozlabs.ibm.com>
On Mon, Mar 02, 2015 at 11:10:51AM +1100, Paul Mackerras wrote:
> The idea looks good; I have a couple of comments on the patch. First,
> 50 tries over 5 seconds seems a bit excessive to me, wouldn't (say) 20
> tries be enough? Is the 50 the result of some analysis?
5 seconds was just my personal feeling where "too long" is
starting.
I have made some quick experiment: I opened ~10 instances
and closing them with group close in Windows 7. With 1
second wait it often can hit the error while closing several
instances at once. With 20 seemed to work reliably. Will
look a bit more though, maybe also handle the failing case
more nice, to avoid having leftover.
The interval of 100 milliseconds was also voluntary. Maybe
need to measure how long the saving actually takes.
>
>> + error_popup "Probably there is stale $config_file_tmp file; config saving is going to fail. Check if it is being used by any existing gitk process and remove it otherwise"
>
> I would word this as "There appears to be a stale $config_file_tmp
> file, which will prevent gitk from saving its configuration on exit.
> Please remove it if it is not being used by any existing gitk
> process."
ok, will change it
> > @@ -2811,11 +2824,16 @@ proc savestuff {w} {
> >
> > if {$stuffsaved} return
> > if {![winfo viewable .]} return
> > + set remove_tmp 0
> > catch {
> > - if {[file exists $config_file_tmp]} {
> > - file delete -force $config_file_tmp
> > + set try_count 0
> > + while {[catch {set f [open $config_file_tmp {WRONLY CREAT EXCL}]}]} {
> > + if {[incr try_count] > 50} {
> > + error "Unable to write config file: $config_file_tmp exists"
> > + }
> > + after 100
> > }
> > - set f [open $config_file_tmp w]
> > + set remove_tmp 1
> > if {$::tcl_platform(platform) eq {windows}} {
> > file attributes $config_file_tmp -hidden true
> > }
> > @@ -2878,6 +2896,14 @@ proc savestuff {w} {
> > puts $f "}"
> > close $f
> > file rename -force $config_file_tmp $config_file
> > + set remove_tmp 0
> > + return ""
> > + } err
> > + if {$err ne ""} {
> > + puts "Error saving config: $err"
>
> I would suggest checking the return from the catch statement, like
> this:
> ...
> rather than doing a return inside the catch.
Yes, I can make proper error handling. Then I think it would better be a separated patch.
--
Max
prev parent reply other threads:[~2015-03-02 20:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-09 22:20 [PATCH v4 0/2] gitk: save only changed configuration on exit Max Kirillov
2014-11-09 22:20 ` [PATCH v4 1/2] gitk: write only changed configuration variables Max Kirillov
2015-03-01 23:47 ` Paul Mackerras
2015-03-02 20:34 ` Max Kirillov
2014-11-09 22:20 ` [PATCH v4 2/2] gitk: synchronize config write Max Kirillov
2015-03-02 0:10 ` Paul Mackerras
2015-03-02 20:43 ` Max Kirillov [this message]
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=20150302204354.GB7622@wheezy.local \
--to=max@max630.net \
--cc=git@vger.kernel.org \
--cc=paulus@samba.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).