Re: Log file with mkstemp() suffix or not? Re: r15435

2010-03-04 Thread Christian Stimming
Am Donnerstag, 4. März 2010 schrieb Bill Nottingham:
> Christian Stimming (stimm...@tuhh.de) said:
> > Can someone explain to me the intention of the following code (...)
> > From reading the code, I
> > guess it should mean "Open gnucash.trace.KSHDJS as trace file and
> > immediately after opening it, rename it back into gnucash.trace".
> 
> That's what's intended, yes. And it works for  me.

Thanks for confirming this. It seems this indeed works on Linux and other 
Unix-like OS, but apparently it never worked on Windows (mingw). There, the 
temp directory gets filled over time with all the gnucash.trace.ABCDEF files.

Seems like we need a completely different implementation of this for the 
G_OS_WIN32 part.

Regards,

Christian
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Log file with mkstemp() suffix or not? Re: r15435

2010-03-04 Thread Bill Nottingham
Christian Stimming (stimm...@tuhh.de) said: 
> Can someone explain to me the intention of the following code that
> initialiizes the trace file output file descriptor (from
> src/libqof/qof/qoflog.c:157ff)
> 
>   fname = g_strconcat(log_filename, ".XX", NULL);
>   if ((fd = g_mkstemp(fname)) != -1)
>   {
>   g_rename(fname, log_filename);
>   fout = fdopen(fd, "w");
>   }
> 
> where log_filename=="/tmp/gnucash.trace", so that fname will be
> something like "/tmp/gnucash.trace.KSHDJS". From reading the code, I
> guess it should mean "Open gnucash.trace.KSHDJS as trace file and
> immediately after opening it, rename it back into gnucash.trace".
> That's at least what the introduction of this code in
> http://svn.gnucash.org/trac/changeset/15435 suggests.

That's what's intended, yes. And it works for  me.

...
12566 open("/home/notting/tmp/gnucash.trace.RNY78U", O_RDWR|O_CREAT|O_EXCL,
0600) = 3
12566 rename("/home/notting/tmp/gnucash.trace.RNY78U",
"/home/notting/tmp/gnucash.trace") = 0
...

Bill
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Log file with mkstemp() suffix or not? Re: r15435

2010-03-01 Thread Christian Stimming
Can someone explain to me the intention of the following code that  
initialiizes the trace file output file descriptor (from  
src/libqof/qof/qoflog.c:157ff)


  fname = g_strconcat(log_filename, ".XX", NULL);
  if ((fd = g_mkstemp(fname)) != -1)
  {
  g_rename(fname, log_filename);
  fout = fdopen(fd, "w");
  }

where log_filename=="/tmp/gnucash.trace", so that fname will be  
something like "/tmp/gnucash.trace.KSHDJS". From reading the code, I  
guess it should mean "Open gnucash.trace.KSHDJS as trace file and  
immediately after opening it, rename it back into gnucash.trace".  
That's at least what the introduction of this code in  
http://svn.gnucash.org/trac/changeset/15435 suggests.


However, this isn't what is happening. Instead, the trace files keep  
their suffix so that in /tmp, plenty of .gnucash.trace.ABCDEF files  
will accumulate over time. Doesn't this mean this code is wrong?


I'm asking because on win32/MSVC, I get a failed runtime assertion in  
libc at the g_rename. This might be because on Windows, the OS does  
not allow opened files to be renamed, but in any case  
g_file_open_tmp() is probably the better choice for win32 anyway.


But for Linux, the question is still what this code should have  
achieved and why it doesn't achieve this?


Puzzled,

Christian



___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel