67b60cf9871635f699d2742c12fe6ed9fd2008a4
1 Description: rrdtool plugin: fix thread-safety detection
2 librrd 1.6.0 is now threadsafe and librrd_th is gone.
3 .
4 Since there doesn't seem to be a way to detect that librrd
5 is threadsafe, use pkg-config to check for 1.6.0 or newer instead.
6 .
7 The logic is now as follows:
8 Check for librrd >= 1.6.0 with pkg-config
9 If not found, look for rrd_update_r in librrd_th.
10 If not found, look for rrd_update in librrd and assume librrd is not
11 thread safe.
12 Author: Ruben Kerkhof <ruben@rubenkerkhof.com>
13 Origin: upstream,
14 commit:ef43260cd901847220c2a9de400579ff903ca13e,
15 commit:32c0ce39f786c56e9d13f3615253a7ae55b578e6,
16 commit:f7e09269879b74e61324de9178503221b2df9136,
17 commit:38068ecc7922ace29bb6af3f8ee5568c3fe96c08
18 Bug-Debian: https://bugs.debian.org/823012
19 Reviewed-By: Jean-Michel Vourgere <nirgal@debian.org>
20 Last-Update: 2016-05-01
22 Index: collectd-5.5.1/configure.ac
23 ===================================================================
24 --- collectd-5.5.1.orig/configure.ac
25 +++ collectd-5.5.1/configure.ac
26 @@ -3942,76 +3942,102 @@ AM_CONDITIONAL(BUILD_WITH_LIBROUTEROS, t
27 # }}}
29 # --with-librrd {{{
30 -# AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
31 librrd_cflags=""
32 librrd_ldflags=""
33 -librrd_threadsafe="yes"
34 +librrd_threadsafe="no"
35 librrd_rrdc_update="no"
36 -AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
37 -[ if test "x$withval" != "xno" && test "x$withval" != "xyes"
38 - then
39 - librrd_cflags="-I$withval/include"
40 - librrd_ldflags="-L$withval/lib"
41 - with_librrd="yes"
42 - else
43 - with_librrd="$withval"
44 - fi
45 -], [with_librrd="yes"])
46 +AC_ARG_WITH(librrd,
47 + [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
48 + [
49 + if test "x$withval" != "xno" && test "x$withval" != "xyes"
50 + then
51 + librrd_cflags="-I$withval/include"
52 + librrd_ldflags="-L$withval/lib"
53 + with_librrd="yes"
54 + else
55 + with_librrd="$withval"
56 + fi
57 + ],
58 + [with_librrd="yes"]
59 +)
60 +
61 if test "x$with_librrd" = "xyes"
62 then
63 - SAVE_CPPFLAGS="$CPPFLAGS"
64 - SAVE_LDFLAGS="$LDFLAGS"
65 + SAVE_LDFLAGS="$LDFLAGS"
66 + LDFLAGS="$LDFLAGS $librrd_ldflags"
67 + PKG_CHECK_MODULES([RRD], [librrd >= 1.6.0],
68 + [
69 + AC_CHECK_LIB([rrd], [rrd_update_r],
70 + [librrd_threadsafe="yes"],
71 + [:]
72 + )
73 + AC_CHECK_LIB([rrd], [rrdc_update],
74 + [librrd_rrdc_update="yes"],
75 + [:]
76 + )
77 + ],[:]
78 + )
79 + LDFLAGS="$SAVE_LDFLAGS"
81 - CPPFLAGS="$CPPFLAGS $librrd_cflags"
82 - LDFLAGS="$LDFLAGS $librrd_ldflags"
83 + SAVE_CPPFLAGS="$CPPFLAGS"
84 + CPPFLAGS="$CPPFLAGS $RRD_CFLAGS $librrd_cflags"
86 - AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
87 + AC_CHECK_HEADERS([rrd.h],, [with_librrd="no (rrd.h not found)"])
89 - CPPFLAGS="$SAVE_CPPFLAGS"
90 - LDFLAGS="$SAVE_LDFLAGS"
91 + CPPFLAGS="$SAVE_CPPFLAGS"
92 fi
93 -if test "x$with_librrd" = "xyes"
94 +
95 +if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"
96 then
97 - SAVE_CPPFLAGS="$CPPFLAGS"
98 - SAVE_LDFLAGS="$LDFLAGS"
99 + SAVE_LDFLAGS="$LDFLAGS"
100 + LDFLAGS="$LDFLAGS $librrd_ldflags"
102 - CPPFLAGS="$CPPFLAGS $librrd_cflags"
103 - LDFLAGS="$LDFLAGS $librrd_ldflags"
104 + AC_CHECK_LIB([rrd_th], [rrd_update_r],
105 + [
106 + librrd_ldflags="$librrd_ldflags -lrrd_th"
107 + librrd_threadsafe="yes"
108 + AC_CHECK_LIB([rrd_th], [rrdc_update],
109 + [librrd_rrdc_update="yes"],
110 + [:],
111 + )
112 + ],
113 + [:]
114 + )
115 + LDFLAGS="$SAVE_LDFLAGS"
116 +fi
118 - AC_CHECK_LIB(rrd_th, rrd_update_r,
119 - [with_librrd="yes"
120 - librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
121 - ],
122 - [librrd_threadsafe="no"
123 - AC_CHECK_LIB(rrd, rrd_update,
124 - [with_librrd="yes"
125 - librrd_ldflags="$librrd_ldflags -lrrd -lm"
126 - ],
127 - [with_librrd="no (symbol 'rrd_update' not found)"],
128 - [-lm])
129 - ],
130 - [-lm])
131 -
132 - if test "x$librrd_threadsafe" = "xyes"
133 - then
134 - AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
135 - else
136 - AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
137 - fi
138 +if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"
139 +then
140 + SAVE_LDFLAGS="$LDFLAGS"
141 + LDFLAGS="$LDFLAGS $librrd_ldflags"
143 - CPPFLAGS="$SAVE_CPPFLAGS"
144 - LDFLAGS="$SAVE_LDFLAGS"
145 + AC_CHECK_LIB([rrd], [rrd_update],
146 + [
147 + librrd_ldflags="$librrd_ldflags -lrrd"
148 + AC_CHECK_LIB([rrd], [rrdc_update],
149 + [librrd_rrdc_update="yes"],
150 + [:]
151 + )
152 + ],
153 + [with_librrd="no (symbol 'rrd_update' not found)"]
154 + )
155 + LDFLAGS="$SAVE_LDFLAGS"
156 fi
157 +
158 if test "x$with_librrd" = "xyes"
159 then
160 - BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
161 - BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
162 - AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
163 - AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
164 + BUILD_WITH_LIBRRD_CFLAGS="$RRD_CFLAGS $librrd_cflags"
165 + BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
166 + BUILD_WITH_LIBRRD_LIBS="$RRD_LIBS"
167 + AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
168 + AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
169 + AC_SUBST(BUILD_WITH_LIBRRD_LIBS)
170 fi
171 if test "x$librrd_threadsafe" = "xyes"
172 then
173 - AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
174 + AC_DEFINE([HAVE_THREADSAFE_LIBRRD], [1],
175 + [Define to 1 if the rrd library is thread-safe]
176 + )
177 fi
178 # }}}
180 Index: collectd-5.5.1/src/Makefile.am
181 ===================================================================
182 --- collectd-5.5.1.orig/src/Makefile.am
183 +++ collectd-5.5.1/src/Makefile.am
184 @@ -876,17 +876,17 @@ endif
185 if BUILD_PLUGIN_RRDCACHED
186 pkglib_LTLIBRARIES += rrdcached.la
187 rrdcached_la_SOURCES = rrdcached.c utils_rrdcreate.c utils_rrdcreate.h
188 -rrdcached_la_LDFLAGS = $(PLUGIN_LDFLAGS)
189 +rrdcached_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBRRD_LDFLAGS)
190 rrdcached_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBRRD_CFLAGS)
191 -rrdcached_la_LIBADD = $(BUILD_WITH_LIBRRD_LDFLAGS)
192 +rrdcached_la_LIBADD = $(BUILD_WITH_LIBRRD_LIBS)
193 endif
195 if BUILD_PLUGIN_RRDTOOL
196 pkglib_LTLIBRARIES += rrdtool.la
197 rrdtool_la_SOURCES = rrdtool.c utils_rrdcreate.c utils_rrdcreate.h
198 -rrdtool_la_LDFLAGS = $(PLUGIN_LDFLAGS)
199 +rrdtool_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBRRD_LDFLAGS)
200 rrdtool_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBRRD_CFLAGS)
201 -rrdtool_la_LIBADD = $(BUILD_WITH_LIBRRD_LDFLAGS)
202 +rrdtool_la_LIBADD = $(BUILD_WITH_LIBRRD_LIBS)
203 endif
205 if BUILD_PLUGIN_SENSORS