[rrd-developers] Introducing librrd_th

Peter Stamfest peter at stamfest.at
Sat Feb 22 22:48:19 MET 2003

Dear RRD enthusiasts ;-)

Over the last two weeks I have exchanged e-Mails and patches with Tobias 
to make the RRD library multi-thread capable in order to be able to link 
it with multi-threaded applications wanting to deal with RRD files 
natively. The best thing is: Tobi has actually accepted the patches, so 
this stuff is already in CVS.

In the light of my recent work, the original patch to 1.0.40 posted two 
weeks ago should be considered broken and should not be used.

The main problems arose from the use of a bunch of global variables and 
non-thread safe library functions. I have solved those problems by

1) Replacing global variables by thread-specific variables much like 
   thread-safe C-libraries/systems do it for the well known errno 
2) Replacing non-thread safe library functions by thread safe 
   counterparts. This includes the elimination of calls to getopt in 
   multi-thread safe code paths (or rather: avoiding calls by providing
   new entry points after getopt parsing...).

All of this requires some support code that has been added in new and 
old source files and a lot of changes all over RRD.

These changes result in the generation of two versions of the RRD library:

a) librrd.a / librrd.so is the well known not-thread-safe version of the 
   library as used by the rrdtool command line utility.
b) librrd_th.a / librrd_th.so is the new thread-safe version of the 
   library. The core stuff is identical, Just the thread-safety stuff can 
   only be found in this version. This version currently requires a 
   pthreads implementation and has only been tested on Linux systems.

There is some documentation of what pitfalls have to be expected in 

I think that thread-safe RRD is not only useful for me, but it might also 
be very useful for bindings to other multi-threaded languages like JAVA 
and PHP (eg. in Apache 2). Any feedback is welcome.

I would like to thank Tobi for accepting my patches.


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