<br><br><div class="gmail_quote">On Wed, Jun 2, 2010 at 12:18 AM, Tobias Oetiker <span dir="ltr"><<a href="mailto:tobi@oetiker.ch">tobi@oetiker.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Kevin,<br>
<div class="im"><br>
Yesterday kevin brintnall wrote:<br>
<br>
> A couple questions for Tobi...<br>
><br>
> (1) should rrd_update_r() call rrd_clear_error() at the top? Its return<br>
> call depends on rrd_test_error(). Would it make sense to save/clear/reset<br>
> the error? Not sure on this.<br>
<br>
</div>well, the way the error flag is handled until now (theoretically)<br>
is, that whoever calls rrd_* functions has to rrd_clear_error prior to<br>
calling the function, and after calling the function the should<br>
check for errors ...<br>
<br>
this is modeled after errno(3) </blockquote><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
For some system calls and library functions (e.g.,<br>
getpriority(2)), -1 is a valid return on success. In such cases,<br>
a successful return can be distinguished from an error return by<br>
setting errno to zero before the call, and then, if the call<br>
returns a status that indicates that an error may have occurred,<br>
checking to see if errno has a non-zero value.<br>
<br>
I did a quick grep for this in program/src and find that it is<br>
mostly true except for a few cases. So the behaviour is quite<br>
consistant but only just ...<br>
<br>
as for rrd_update (and some others) doing stuff with rrd_test_error<br>
internally, I guess this is the real culprit as this is not in line<br>
with the behaviour you get from errno ...<br>
<br>
so I guess the parts of code that do use rrd_test_error internally<br>
should 'push' the prior state of rrd_error when they start working<br>
and at the very end 'pop' it if no error has been set. <br></blockquote><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
does this make sense ?<br></blockquote><div><br>I understand what you're saying, but save/restore or push/pop would likely complicate the code. As long as users of the API can think of it in terms of errno, it's probably best to leave it as-is?<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
> (2) Should we expose rrd_info_r ?<br>
<br>
</div>aehm ... this is already exposed I think.<br>
</blockquote><div><br><br>Quite right.. my mistake.<br><br>-kb<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">cheers<br>
tobi<br>
<div><div></div><div class="h5">><br>
> -kb<br>
><br>
> On Tue, Jun 1, 2010 at 7:42 AM, Tomáš Macek <<a href="mailto:maca02@atlas.cz">maca02@atlas.cz</a>> wrote:<br>
><br>
> > Hm, so rrd_clear_error() did the job. I inserted call of rrd_clear_error()<br>
> > before each rrd_*() calling and program works (see the line with<br>
> > "attention" comment). I've tried to simplify things as possible and here<br>
> > it is, maybe this will help to anyone else to solve his problems... Am I<br>
> > doing everything right now?<br>
> ><br>
> > Tomas<br>
> ><br>
> > -------------------------<br>
> ><br>
> > #include <stdio.h><br>
> > #include <sys/types.h><br>
> > #include <unistd.h><br>
> > #include <stdlib.h><br>
> > #include <stdarg.h><br>
> > #include <rrd.h><br>
> ><br>
> > void rrd_cmd(char *cmdstr) {<br>
> > char *strptr = NULL, *str = NULL;<br>
> > char *argv[64];<br>
> > int error = 0, i = 0;<br>
> > rrd_info_t *it = NULL;<br>
> > char rrdcmd[2048] = "";<br>
> ><br>
> > snprintf(rrdcmd, 2048, "%s", cmdstr);<br>
> ><br>
> > i = 0;<br>
> ><br>
> > /* memset update, create *argv[] */<br>
> > memset(argv, 0, 64 * sizeof(char *));<br>
> ><br>
> > for (strptr = rrdcmd; strptr != NULL;) {<br>
> > while ((str = strsep(&strptr, " ")) != NULL && str != '\0') {<br>
> > argv[i] = str;<br>
> > i++;<br>
> > }<br>
> > }<br>
> ><br>
> > rrd_clear_error(); /* attention!!! */<br>
> > it = rrd_info(i, argv);<br>
> > rrd_info_free(it);<br>
> > rrd_clear_error(); /* attention!!! */<br>
> > error = rrd_update(i, argv);<br>
> > if (error == -1) {<br>
> > printf("Error: RRD_UPDATE command: %s\n", rrd_get_error());<br>
> > rrd_clear_error();<br>
> > }<br>
> > }<br>
> ><br>
> > int update_rrd_cmd(char *rrd_name, char *ds_string, char *n_value_string,<br>
> > char *buff, int n) {<br>
> > memset(buff, 0, n);<br>
> > snprintf(buff, n, "update %s --template %s %s", rrd_name, ds_string,<br>
> > n_value_string);<br>
> > printf("%s: buff = %s\n", __FUNCTION__, buff);<br>
> > return 0;<br>
> > }<br>
> ><br>
> > int main(void) {<br>
> > char buff[2048] = "";<br>
> > update_rrd_cmd("./testfile.rrd", "ds0:ds1", "N:123:456", buff, 2048);<br>
> > rrd_cmd(buff);<br>
> > return 0;<br>
> > }<br>
> ><br>
> ><br>
> > On Tue, 01 Jun 2010 08:20:18 +0200, Tomáš Macek <<a href="mailto:maca02@atlas.cz">maca02@atlas.cz</a>> wrote:<br>
> ><br>
> > > Hello again,<br>
> > > this problem is present since 1.4.0. I know it, because I've tried every<br>
> > > version since 1.3.8 (works), through 1.3.9 (works), 1.4.0 - 1.4.3 does<br>
> > > not<br>
> > > work at all with syntax error as described below. Everytime I compiled<br>
> > > and<br>
> > > tried the same source code and linked with the proper library version.<br>
> > > What has changed in the API of rrd_update() in 1.4.0? I really don't<br>
> > > understand what I'm doing wrong. Any hints/help appreciated, looking at<br>
> > > the CHANGES file did not helped me.<br>
> > ><br>
> > > Tomas<br>
> > ><br>
> > ><br>
> > > On Thu, 20 May 2010 12:28:25 +0200, Tomáš Macek <<a href="mailto:maca02@atlas.cz">maca02@atlas.cz</a>> wrote:<br>
> > ><br>
> > >> Hi, I have RHEL 5.5 with rrdtool 1.4.3 and I'm using it's API for<br>
> > >> updating<br>
> > >> rrd files. The problem is that when I pass arguments to the rrd_update()<br>
> > >> function, it always returns error saying "Usage: rrdtool update<br>
> > >> [--daemon<br>
> > >> <addr>] <file>". The same code worked really fine on 1.3.8. I looked at<br>
> > >> the CHANGELOG file and there was some line saying, that something has<br>
> > >> changed on checking optarg parameters.<br>
> > >><br>
> > >> This is from gdb just before I pass the array into rrd_update()<br>
> > >> function:<br>
> > >> -----------<br>
> > >> Breakpoint 2, rrd_cmd (rrdcmd=0x634dc0 "update", cmd=1, di_cnt=2) at<br>
> > >> rrd_op.c:215<br>
> > >> 215 error = rrd_update(i, argv);<br>
> > >> (gdb) p argv<br>
> > >> $26 = {0x634dc0 "update", 0x634dc7 "cac_ap2aeth.rrd",<br>
> > >> 0x634e06 "--template", 0x634e11 "ds0:ds1", 0x634e19<br>
> > >> "N:2325779922:3582706806", 0x0 <repeats 59 times>}<br>
> > >> -----------<br>
> > >><br>
> > >> and after program goes thourgh rrd_update(), the argv array looks like<br>
> > >> this:<br>
> > >> -----------<br>
> > >> 216 if (error == -1) {<br>
> > >> (gdb) p argv<br>
> > >> $28 = {0x634dc0 "update", 0x634e06 "--template", 0x634e11 "ds0:ds1",<br>
> > >> 0x634dc7 "cac_ap2aeth.rrd", 0x634e19 "N:2325779922:3582706806",<br>
> > >> 0x0 <repeats 59 times>}<br>
> > >> -----------<br>
> > >><br>
> > >> Please, notice the replaced arguments after rrd_update()... I don't<br>
> > >> know,<br>
> > >> what I'm doing wrong, the code under 1.3.8 library worked just fine and<br>
> > >> according to the man rrdupdate the arguments are fine. Hope I'm not<br>
> > >> missing something stupid, but I was not able to find anything strange in<br>
> > >> rrd_update() function in the rrd_update.c.<br>
> > >> Let me know, if you need something more from me, thank you<br>
> > >><br>
> > >> Regards, Tomas<br>
> > >><br>
> > >> _______________________________________________<br>
> > >> rrd-developers mailing list<br>
> > >> <a href="mailto:rrd-developers@lists.oetiker.ch">rrd-developers@lists.oetiker.ch</a><br>
> > >> <a href="https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers" target="_blank">https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers</a><br>
> > ><br>
> > > _______________________________________________<br>
> > > rrd-developers mailing list<br>
> > > <a href="mailto:rrd-developers@lists.oetiker.ch">rrd-developers@lists.oetiker.ch</a><br>
> > > <a href="https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers" target="_blank">https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers</a><br>
> ><br>
> > _______________________________________________<br>
> > rrd-developers mailing list<br>
> > <a href="mailto:rrd-developers@lists.oetiker.ch">rrd-developers@lists.oetiker.ch</a><br>
> > <a href="https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers" target="_blank">https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers</a><br>
> ><br>
><br>
><br>
><br>
><br>
<br>
--<br>
</div></div>Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland<br>
<a href="http://it.oetiker.ch" target="_blank">http://it.oetiker.ch</a> <a href="mailto:tobi@oetiker.ch">tobi@oetiker.ch</a> ++41 62 775 9902 / sb: -9900</blockquote></div><br><br clear="all"><br>-- <br> kevin brintnall =~ /<a href="http://kbrint@rufus.net/">kbrint@rufus.net/</a><br>
<br>