confuse-devel
[Top][All Lists]
Advanced

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

Re: [Confuse-devel] bug?


From: Freddy
Subject: Re: [Confuse-devel] bug?
Date: Sun, 23 Mar 2003 18:58:10 +0100

> > 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.

In more detail, I have a function called 'conf_refresh', which does the 
re-reading of the config.
This fuction defines the cfgopt_t type-variables. I use this line for my 
sections (with those flags you wrote):
'CFG_SEC("section", section_opts, CFGF_MULTI | CFGF_TITLE)'. Is that a problem 
that these
cfgopt_t type-arrays are defined every time when I call the funcion 
conf_refresh?
Anyway, I always call cfg_free() before I return from the funtion even if one 
of the functions (e.g. cfg_parse)
gives back an error so I have to return immediately. I have tried to put 
additional cfg_free()-s in different
places as well, unfortunately it didn't help..

Thanks,
Freddy




reply via email to

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