™.. RRDTHREADS - Online Linux Manual PageSection : 1
Updated : 2008-06-08
Source : 1.3.8
Note : rrdtool

NAMErrdthreads − Provisions for linking the RRD library to use in multi−threaded programs

SYNOPSISUsing librrd in multi-threaded programs requires some extra precautions, as the RRD library in its original form was not thread-safe at all. This document describes requirements and pitfalls on the way to use the multi-threaded version of librrd in your own programs. It also gives hints for future RRD development to keep the library thread-safe. Currently only some RRD operations are implemented in a thread-safe way. They all end in the usual "\*(C`_r\*(C'\fR" suffix.

DESCRIPTIONIn order to use librrd in multi-threaded programs you must: • Link with librrd_th instead of librrd (use \*(C`\-lrrd_th\*(C'\fR when linking) • Use the "\*(C`_r\*(C'\fR" functions instead of the normal API-functions • Do not use any at-style time specifications. Parsing of such time specifications is terribly non-thread-safe. • Never use non *\*(C`_r\*(C'\fR functions unless it is explicitly documented that the function is tread-safe. • Every thread SHOULD call \*(C`rrd_get_context()\*(C'\fR before its first call to any \*(C`librrd_th\*(C'\fR function in order to set up thread specific data. This is not strictly required, but it is the only way to test if memory allocation can be done by this function. Otherwise the program may die with a SIGSEGV in a low-memory situation. • Always call \*(C`rrd_error_clear()\*(C'\fR before any call to the library. Otherwise the call might fail due to some earlier error.

NOTES FOR RRD CONTRIBUTORSSome precautions must be followed when developing RRD from now on: • Only use thread-safe functions in library code. Many often used libc functions aren't thread-safe. Take care in the following situations or when using the following library functions: • Direct calls to \*(C`strerror()\*(C'\fR must be avoided: use \f(CW\*(C`rrd_strerror()\*(C'\fR instead, it provides a per-thread error message. • The \*(C`getpw*\*(C'\fR, \f(CW\*(C`getgr*\*(C'\fR, \f(CW\*(C`gethost*\*(C'\fR function families (and some more ​\*(C`get*\*(C'\fR functions) are not thread-safe: use the *\f(CW\*(C`_r\*(C'\fR variants • Time functions: \*(C`asctime\*(C'\fR, \f(CW\*(C`ctime\*(C'\fR, \f(CW\*(C`gmtime\*(C'\fR, \f(CW\*(C`localtime\*(C'\fR: use *\*(C`_r\*(C'\fR variants • \*(C`strtok\*(C'\fR: use \f(CW\*(C`strtok_r\*(C'\fR • \*(C`tmpnam\*(C'\fR: use \f(CW\*(C`tmpnam_r\*(C'\fR • Many others (lookup documentation) • A header file named rrd_is_thread_safe.h is provided that works with the GNU C−preprocessor to poison some of the most common non-thread-safe functions using the \*(C`#pragma GCC poison\*(C'\fR directive. Just include this header in source files you want to keep thread-safe. • Do not introduce global variables! If you really, really have to use a global variable you may add a new field to the \*(C`rrd_context\*(C'\fR structure and modify \fIrrd_error.c\fR, ​rrd_thread_safe.c and rrd_non_thread_safe.c • Do not use \*(C`getopt\*(C'\fR or \f(CW\*(C`getopt_long\*(C'\fR in *\f(CW\*(C`_r\*(C'\fR (neither directly nor indirectly). \*(C`getopt\*(C'\fR uses global variables and behaves badly in a multi-threaded application when called concurrently. Instead provide a *_r function taking all options as function parameters. You may provide argc and **argv arguments for variable length argument lists. See ​\*(C`rrd_update_r\*(C'\fR as an example. • Do not use the \*(C`rrd_parsetime\*(C'\fR function! It uses lots of global variables. You may use it in functions not designed to be thread-safe, like in functions wrapping the \*(C`_r\*(C'\fR version of some operation (e.g., \*(C`rrd_create\*(C'\fR, but not in \f(CW\*(C`rrd_create_r\*(C'\fR)

CURRENTLY IMPLEMENTED THREAD SAFE FUNCTIONSCurrently there exist thread-safe variants of \*(C`rrd_update\*(C'\fR, ​\*(C`rrd_create\*(C'\fR, \f(CW\*(C`rrd_dump\*(C'\fR, \f(CW\*(C`rrd_info\*(C'\fR, \f(CW\*(C`rrd_last\*(C'\fR, and \f(CW\*(C`rrd_fetch\*(C'\fR.

AUTHORPeter Stamfest <peter@stamfest.at>
0
Johanes Gumabo
Data Size   :   16,450 byte
man-rrdthreads.1Build   :   2024-12-29, 07:25   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   5 / 258,850
Visitor ID   :     :  
Visitor IP   :   18.117.156.84   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.29
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (parse_manual_page_|252|rrdthreads.1|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\| )         (htmlprn|149|rrdthreads.1|36/37|.el══─{─══. ds --  —  |.el══─{─══. ds -- \|\(em\| )         (parse_manual_page_|252|rrdthreads.1|41|br══─}─══|'br══─}─══ )         (htmlprn|149|rrdthreads.1|41|'br══─}─══ |'br══─}─══ )         (rof_nr_x|149|rrdthreads.1|51/52|\nF|.ie \nF ══─{─══. de IX )         (rof_unit_scale_px|41|rrdthreads.1|51/52|F|.ie \nF ══─{─══. de IX )         (rof_if|19|rrdthreads.1|51/52|\nF|.ie \nF ══─{─══. de IX )         (htmlprn|149|rrdthreads.1|51/52|.ie \nF ══─{─══. de IX|.ie \nF ══─{─══. de IX )         (rof_escape_sequence|91|rrdthreads.1|53|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2" )         (parse_manual_page_|252|rrdthreads.1|57|══─}─══|.══─}─══ )         (htmlprn|149|rrdthreads.1|57|.══─}─══ |.══─}─══ )         (rof_escape_sequence|91|rrdthreads.1|144|\*(C`_r\*(C'\fR" suffix. |way. They all end in the usual "\f(CW\*(C`_r\*(C'\fR" suffix. )         (rof_escape_sequence|91|rrdthreads.1|149|\*(C`\-lrrd_th\*(C'\fR when |Link with \fIlibrrd_th\fR instead of \fIlibrrd\fR (use \f(CW\*(C`\-lrrd_th\*(C'\fR when )         (rof_escape_sequence|91|rrdthreads.1|152|\*(C`_r\*(C'\fR" functions instead of the normal API-functions |Use the "\f(CW\*(C`_r\*(C'\fR" functions instead of the normal API-functions )         (rof_escape_sequence|91|rrdthreads.1|157|\*(C`_r\*(C'\fR functions unless it is explicitly documented that |Never use non *\f(CW\*(C`_r\*(C'\fR functions unless it is explicitly documented that )         (rof_escape_sequence|91|rrdthreads.1|160|\*(C`rrd_get_context()\*(C'\fR before its first call to |Every thread \s-1SHOULD\s0 call \f(CW\*(C`rrd_get_context()\*(C'\fR before its first call to )         (rof_escape_sequence|91|rrdthreads.1|161|\*(C`librrd_th\*(C'\fR function in order to set up thread specific data. This |any \f(CW\*(C`librrd_th\*(C'\fR function in order to set up thread specific data. This )         (rof_escape_sequence|91|rrdthreads.1|166|\*(C`rrd_error_clear()\*(C'\fR before any call to the |Always call \f(CW\*(C`rrd_error_clear()\*(C'\fR before any call to the )         (rof_escape_sequence|91|rrdthreads.1|177|\*(C`strerror()\*(C'\fR must be avoided: use \f(CW\*(C`rrd_strerror()\*(C'\fR |Direct calls to \f(CW\*(C`strerror()\*(C'\fR must be avoided: use \f(CW\*(C`rrd_strerror()\*(C'\fR )         (rof_escape_sequence|91|rrdthreads.1|180|\*(C`getpw*\*(C'\fR, \f(CW\*(C`getgr*\*(C'\fR, \f(CW\*(C`gethost*\*(C'\fR function families (and some more |The \f(CW\*(C`getpw*\*(C'\fR, \f(CW\*(C`getgr*\*(C'\fR, \f(CW\*(C`gethost*\*(C'\fR function families (and some more )         (rof_escape_sequence|91|rrdthreads.1|181|\*(C`get*\*(C'\fR functions) are not thread-safe: use the *\f(CW\*(C`_r\*(C'\fR variants |\&\f(CW\*(C`get*\*(C'\fR functions) are not thread-safe: use the *\f(CW\*(C`_r\*(C'\fR variants )         (rof_escape_sequence|91|rrdthreads.1|183|\*(C`asctime\*(C'\fR, \f(CW\*(C`ctime\*(C'\fR, \f(CW\*(C`gmtime\*(C'\fR, \f(CW\*(C`localtime\*(C'\fR: use |Time functions: \f(CW\*(C`asctime\*(C'\fR, \f(CW\*(C`ctime\*(C'\fR, \f(CW\*(C`gmtime\*(C'\fR, \f(CW\*(C`localtime\*(C'\fR: use )         (rof_escape_sequence|91|rrdthreads.1|184|\*(C`_r\*(C'\fR variants |*\f(CW\*(C`_r\*(C'\fR variants )         (rof_escape_sequence|91|rrdthreads.1|186|\*(C`strtok\*(C'\fR: use \f(CW\*(C`strtok_r\*(C'\fR |\&\f(CW\*(C`strtok\*(C'\fR: use \f(CW\*(C`strtok_r\*(C'\fR )         (rof_escape_sequence|91|rrdthreads.1|188|\*(C`tmpnam\*(C'\fR: use \f(CW\*(C`tmpnam_r\*(C'\fR |\&\f(CW\*(C`tmpnam\*(C'\fR: use \f(CW\*(C`tmpnam_r\*(C'\fR )         (rof_escape_sequence|91|rrdthreads.1|197|\*(C`#pragma GCC poison\*(C'\fR |common non-thread-safe functions using the \f(CW\*(C`#pragma GCC poison\*(C'\fR )         (rof_escape_sequence|91|rrdthreads.1|204|\*(C`rrd_context\*(C'\fR structure and modify \fIrrd_error.c\fR, |field to the \f(CW\*(C`rrd_context\*(C'\fR structure and modify \fIrrd_error.c\fR, )         (rof_escape_sequence|91|rrdthreads.1|207|\*(C`getopt\*(C'\fR or \f(CW\*(C`getopt_long\*(C'\fR in *\f(CW\*(C`_r\*(C'\fR (neither directly nor |Do not use \f(CW\*(C`getopt\*(C'\fR or \f(CW\*(C`getopt_long\*(C'\fR in *\f(CW\*(C`_r\*(C'\fR (neither directly nor )         (rof_escape_sequence|91|rrdthreads.1|210|\*(C`getopt\*(C'\fR uses global variables and behaves badly in a multi-threaded |\&\f(CW\*(C`getopt\*(C'\fR uses global variables and behaves badly in a multi-threaded )         (rof_escape_sequence|91|rrdthreads.1|214|\*(C`rrd_update_r\*(C'\fR as an example. |\&\f(CW\*(C`rrd_update_r\*(C'\fR as an example. )         (rof_escape_sequence|91|rrdthreads.1|216|\*(C`rrd_parsetime\*(C'\fR function! |Do not use the \f(CW\*(C`rrd_parsetime\*(C'\fR function! )         (rof_escape_sequence|91|rrdthreads.1|219|\*(C`_r\*(C'\fR version of some |to be thread-safe, like in functions wrapping the \f(CW\*(C`_r\*(C'\fR version of some )         (rof_escape_sequence|91|rrdthreads.1|220|\*(C`rrd_create\*(C'\fR, but not in \f(CW\*(C`rrd_create_r\*(C'\fR) |operation (e.g., \f(CW\*(C`rrd_create\*(C'\fR, but not in \f(CW\*(C`rrd_create_r\*(C'\fR) )         (rof_escape_sequence|91|rrdthreads.1|223|\*(C`rrd_update\*(C'\fR, |Currently there exist thread-safe variants of \f(CW\*(C`rrd_update\*(C'\fR, )         (rof_escape_sequence|91|rrdthreads.1|224|\*(C`rrd_create\*(C'\fR, \f(CW\*(C`rrd_dump\*(C'\fR, \f(CW\*(C`rrd_info\*(C'\fR, \f(CW\*(C`rrd_last\*(C'\fR, and \f(CW\*(C`rrd_fetch\*(C'\fR. |\&\f(CW\*(C`rrd_create\*(C'\fR, \f(CW\*(C`rrd_dump\*(C'\fR, \f(CW\*(C`rrd_info\*(C'\fR, \f(CW\*(C`rrd_last\*(C'\fR, and \f(CW\*(C`rrd_fetch\*(C'\fR. )