[Wether or not to use the pcap library])
AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
+perl_interpreter="perl"
AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
[
if test "x$withval" != "xno" && test "x$withval" != "xyes"
then
LDFLAGS="$LDFLAGS -L$withval/lib"
CPPFLAGS="$CPPFLAGS -I$withval/include"
+ perl_interpreter="$withval/bin/perl"
with_libperl="yes"
fi
],
then
SAVE_CFLAGS=$CFLAGS
SAVE_LDFLAGS=$LDFLAGS
- CFLAGS="$CFLAGS `perl -MExtUtils::Embed -e ccopts`"
- LDFLAGS="$LDFLAGS `perl -MExtUtils::Embed -e ldopts`"
+ PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
+ PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
+ CFLAGS="$CFLAGS $PERL_CFLAGS"
+ LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
AC_CACHE_CHECK([for libperl],
[have_libperl],
[[
PerlInterpreter *perl = NULL;
Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
- Perl_newSVpvf (perl, "Collectd::Plugin::%s", "foo"),
+ newSVpv ("Collectd::Plugin::FooBar", 24),
Nullsv);
]]),
[have_libperl="yes"],
if test "x$have_libperl" = "xyes"
then
AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
+ AC_SUBST(PERL_CFLAGS)
+ AC_SUBST(PERL_LDFLAGS)
else
with_libperl="no"
fi
pkglib_LTLIBRARIES += perl.la
perl_la_SOURCES = perl.c
perl_la_CFLAGS = $(AM_CFLAGS) \
- $(shell perl -MExtUtils::Embed -e ccopts) \
+ $(PERL_CFLAGS) \
-DXS_VERSION=\"$(VERSION)\" -DVERSION=\"$(VERSION)\"
perl_la_LDFLAGS = -module -avoid-version \
- $(shell perl -MExtUtils::Embed -e ldopts)
+ $(PERL_LDFLAGS)
collectd_LDADD += "-dlopen" perl.la
collectd_DEPENDENCIES += perl.la
endif
log_debug ("perl_config: loading perl plugin \"%s\"", value);
Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
- newSVpv (module_name, strlen (module_name)),
+ Perl_newSVpv (perl, module_name, strlen (module_name)),
Nullsv);
}
else if (0 == strcasecmp (key, "BaseName")) {
char *saveptr = NULL;
char *dummy;
char *ptr;
+ char *value_copy;
int *tmp_alloc;
- dummy = value;
+ value_copy = strdup (value);
+ if (value_copy == NULL)
+ return (1);
+
+ dummy = value_copy;
while ((ptr = strtok_r (dummy, ", \t", &saveptr)) != NULL)
{
dummy = NULL;
if (tmp_alloc == NULL)
{
fprintf (stderr, "rrdtool: realloc failed.\n");
+ free (value_copy);
return (1);
}
rra_timespans_custom = tmp_alloc;
if (rra_timespans_custom[rra_timespans_custom_num] != 0)
rra_timespans_custom_num++;
} /* while (strtok_r) */
-
+ free (value_copy);
}
else if (strcasecmp ("XFF", key) == 0)
{
vc = cache_search (name);
+ /* pthread_mutex_lock is called by cache_insert. */
if (vc == NULL)
return (cache_insert (ds, vl));
assert (vc->values_num == ds->ds_num);
assert (vc->values_num == vl->values_len);
+ /* Avoid floating-point exceptions due to division by zero. */
+ if (vc->time >= vl->time)
+ {
+ pthread_mutex_unlock (&cache_lock);
+ ERROR ("unixsock plugin: vc->time >= vl->time. vc->time = %u; "
+ "vl->time = %u; vl = %s;",
+ (unsigned int) vc->time, (unsigned int) vl->time,
+ name);
+ return (-1);
+ } /* if (vc->time >= vl->time) */
+
/*
* Update the values. This is possibly a lot more that you'd expect
* because we honor min and max values and handle counter overflows here.