[rrd-developers] Re: PATCH: rrd_graph / setlocale / librrd
Peter Stamfest
peter at stamfest.at
Thu Apr 24 10:16:08 MEST 2003
On Thu, 24 Apr 2003, Stanislav Sinyagin wrote:
> Date: Thu, 24 Apr 2003 00:38:51 -0700 (PDT)
> From: Stanislav Sinyagin <ssinyagin at yahoo.com>
> To: rrd-developers at list.ee.ethz.ch
> Subject: [rrd-developers] Re: PATCH: rrd_graph / setlocale / librrd
>
> Hi,
>
> and what about the Perl binding? Should it be patched too?
>
>
Well, it has nothing to do with the language bindings themselves. I just
wanted to indicate that language-bindings are often used in a very general
context. Eg. you might have a perl script using RRD. Both RRD and the
program as a wholemight deal with locales. If RRD just sets the locale
every time you call rrd_graph it might influence other program
parts having set a different locale.
Suppose:
-----------------------------------------------
#!/usr/bin/perl
use RRD; # does this exist?
use POSIX;
$loc = POSIX::setlocale(LC_ALL, "es_AR.ISO8859-1");
# call
RRD::graph(...);
# locale might have been changed
$now_string = POSIX::strftime "%a %b %e %H:%M:%S %Y", localtime;
# $now_string may not be what you want it to be
-----------------------------------------------
Actually, in the above example you might want RRD::graph to use the
previously set locale, but instead it uses the locale specified in
the environment (which might be different from the one desired
explicitly).
Rule of thumb: A library should not have any unexpected side-effects.
To answer the question: I do not see a need to patch anything outside RRD
but all programs using librrd ;-)
Language bindings themselves should also not have unexpected side effects,
thus I do not see an immediate effect on language bindings themselves.
They should definitly not call setlocale but leave that job to the
programs using the binding.
peter
>
> --- Peter Stamfest <peter at stamfest.at> wrote:
> > I just stumbled across a possible problem in rrd_graph. That function uses
> > to call tzset and setlocale. When using librrd this is not desirable, as
> > this might override any settings done by the application linking
> > with librrd (language bindings come to mind). Besides, it is possibly not
> > thread-safe ;-) ).
> >
> > Here is a patch to move these calls into the rrdtool binary and removing
> > them from librrd.
> >
> > This adds a new requirement for software using librrd: tzset and setlocale
> > have to be called from the calling application.
>
> --
> Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
> Help mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
> Archive http://www.ee.ethz.ch/~slist/rrd-developers
> WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
>
--
Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the rrd-developers
mailing list