summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 845b2d2)
raw | patch | inline | side by side (parent: 845b2d2)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 3 Dec 2006 09:38:52 +0000 (10:38 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 3 Dec 2006 09:38:52 +0000 (10:38 +0100) |
So far the plugin simply imported `pthread.h'. If this headerfile (or the
library for that case) was not present, building the plugin would fail. This
patch makes `libpthread' a soft dependency, i. e. it's only necessary if you
want to read from the socket. Without `libpthread' being available the plugin
can still be used in server processes.
library for that case) was not present, building the plugin would fail. This
patch makes `libpthread' a soft dependency, i. e. it's only necessary if you
want to read from the socket. Without `libpthread' being available the plugin
can still be used in server processes.
src/Makefile.am | patch | blob | history | |
src/email.c | patch | blob | history |
diff --git a/src/Makefile.am b/src/Makefile.am
index 9e9b4660cf875b5f602b9bcbee88f5188dc68ff3..fcbcb1679f80dce38f077dcd409ab6dbab012b24 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
if BUILD_MODULE_EMAIL
pkglib_LTLIBRARIES += email.la
email_la_SOURCES = email.c
-email_la_LDFLAGS = -module -avoid-version -lpthread
+email_la_LDFLAGS = -module -avoid-version
+if BUILD_WITH_LIBPTHREAD
+email_la_LDFLAGS += -lpthread
+endif
collectd_LDADD += "-dlopen" email.la
collectd_DEPENDENCIES += email.la
endif
diff --git a/src/email.c b/src/email.c
index 37194fb1f6d55575785fe064507488659a53ac9f..8d2c89143177b90097992d1921014ec155fb9797 100644 (file)
--- a/src/email.c
+++ b/src/email.c
#include "common.h"
#include "plugin.h"
-#include <pthread.h>
+#if HAVE_LIBPTHREAD
+# include <pthread.h>
+# define EMAIL_HAVE_READ 1
+#else
+# define EMAIL_HAVE_READ 0
+#endif
#if HAVE_SYS_SELECT_H
# include <sys/select.h>
#define SOCK_PATH "/tmp/.collectd-email"
#define MAX_CONNS 5
+/*
+ * Private data structures
+ */
+#if EMAIL_HAVE_READ
/* linked list of email and check types */
typedef struct type {
char *name;
collector_t *head;
collector_t *tail;
} collector_list_t;
+#endif /* EMAIL_HAVE_READ */
+/*
+ * Private variables
+ */
+#if EMAIL_HAVE_READ
/* state of the plugin */
static int disabled = 0;
static pthread_mutex_t available_mutex = PTHREAD_MUTEX_INITIALIZER;
static collector_list_t available;
+static pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER;
+static type_list_t count;
+
+static pthread_mutex_t size_mutex = PTHREAD_MUTEX_INITIALIZER;
+static type_list_t size;
+
+static pthread_mutex_t score_mutex = PTHREAD_MUTEX_INITIALIZER;
+static double score;
+static int score_count;
+
+static pthread_mutex_t check_mutex = PTHREAD_MUTEX_INITIALIZER;
+static type_list_t check;
+#endif /* EMAIL_HAVE_READ */
+
#define COUNT_FILE "email/email-%s.rrd"
static char *count_ds_def[] =
{
};
static int count_ds_num = 1;
-static pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER;
-static type_list_t count;
-
#define SIZE_FILE "email/email_size-%s.rrd"
static char *size_ds_def[] =
{
};
static int size_ds_num = 1;
-static pthread_mutex_t size_mutex = PTHREAD_MUTEX_INITIALIZER;
-static type_list_t size;
-
#define SCORE_FILE "email/spam_score.rrd"
static char *score_ds_def[] =
{
};
static int score_ds_num = 1;
-static pthread_mutex_t score_mutex = PTHREAD_MUTEX_INITIALIZER;
-static double score;
-static int score_count;
-
#define CHECK_FILE "email/spam_check-%s.rrd"
static char *check_ds_def[] =
{
};
static int check_ds_num = 1;
-static pthread_mutex_t check_mutex = PTHREAD_MUTEX_INITIALIZER;
-static type_list_t check;
-
+#if EMAIL_HAVE_READ
/* Increment the value of the given name in the given list by incr. */
static void type_list_incr (type_list_t *list, char *name, int incr)
{
}
pthread_exit ((void *)0);
} /* void *open_connection (void *) */
+#endif /* EMAIL_HAVE_READ */
static void email_init (void)
{
+#if EMAIL_HAVE_READ
int err = 0;
if (0 != (err = pthread_create (&connector, NULL,
syslog (LOG_ERR, "pthread_create() failed: %s", strerror (err));
return;
}
+#endif /* EMAIL_HAVE_READ */
return;
} /* static void email_init (void) */
return;
} /* static void check_write (char *host, char *inst, char *val) */
+#if EMAIL_HAVE_READ
static void type_submit (char *plugin, char *inst, int value)
{
char buf[BUFSIZE] = "";
pthread_mutex_unlock (&check_mutex);
return;
} /* static void read (void) */
+#else /* if !EMAIL_HAVE_READ */
+# define email_read NULL
+#endif
void module_register (void)
{