confuse-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Confuse-devel] bug?


From: Martin Hedenfalk
Subject: Re: [Confuse-devel] bug?
Date: Sun, 23 Mar 2003 14:35:42 +0100
User-agent: Mutt/1.3.28i

On Sun, Mar 23, 2003 at 07:58:20AM +0100, Freddy wrote:
> Hi!
> 
> I started to write a daemon program in C using libconfuse (version 1.2.3) as 
> its configuration
> file parser. When the daemon starts it reads its configuration file (config 
> later on) and daemonizes
> itself into the background. An important requirement that the config can be 
> re-readed at any time
> without stopping the running daemon program. It works well if the config 
> doesn't contain any errors.
> But I've noticed if I make an error (I simply put an 'x' into the config) 
> libconfuse behaves interesting.
> At the first re-reading attempt it gives a quite correct error message: 
> "xxxx.conf:6: no such option 'x'",
> but second time the line in the error message migrates to the last line of 
> the config:
> "xxxx.conf:72: no such option 'x'".

Hi, this is obviously a bug, the line counter is probably not reset when
re-opening the file.

> After I corrected the config (deleting 'x' from line 6) cfg_size()
> function gives back a false value: two times more sections than I have in 
> fact. Then the daemon
> tries to read the sections sequentially (0,1,2,etc) and it will get the first 
> again when reached the last.
> For example I have three sections then cfg_getnsec() gives back sections in 
> order: 0,1,2,0,1,2

This is the correct behaviour for sections with the CFGF_MULTI flag set.
You'll have to call cfg_free() before re-reading the config file. However,
for titled sections (ie, sections with the CFGF_TITLE flag set), this
behaviour is probably not right. I'll change libconfuse to always overwrite
sections with the same title.

> (when the running code reaches command sec=cfg_getnsec(cfg,"section",3) it 
> will get the first section
> again and so on). At the next re-reading the errors disappear.
> 
> Sorry for my English and I hope my description is clear enough :)
> I would really appreciate any advices in connection with my problem.

A quick solution is to call cfg_free() before re-reading the config file.

Thanks / Martin

-- 
Martin Hedenfalk <address@hidden>
--
Lubarsky's Law of Cybernetic Entomology:
  There's always one more bug.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]