Merge branch 'collectd-4.9'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 15 Mar 2010 21:43:00 +0000 (22:43 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 15 Mar 2010 21:43:00 +0000 (22:43 +0100)
12 files changed:
.mailmap
configure.in
src/common.c
src/common.h
src/configfile.c
src/exec.c
src/memcached.c
src/oracle.c
src/owniptc/libip4tc.c
src/owniptc/libip6tc.c
src/owniptc/libiptc.c
src/processes.c

index 9bb4399..a39a1d2 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -5,4 +5,5 @@ Luboš Staněk <kolektor@atlas.cz>
 Luboš Staněk <lubek@users.sourceforge.net>
 Niki W. Waibel <niki>
 Sebastian Harl <tokkee>
+Rodolphe Quiedeville <rquiedeville@bearstech.com>
 
index a3b2ab6..1193583 100644 (file)
@@ -931,6 +931,27 @@ if test "x$have_getmntent" = "xgen"; then
                  [Define if the function getmntent exists. It's the version from libgen.])
 fi
 
+# Check for htonll
+AC_MSG_CHECKING([if have htonll defined])
+
+    have_htonll="no"
+    AC_RUN_IFELSE([
+       AC_LANG_PROGRAM([
+#include <sys/types.h>
+#include <netinet/in.h>
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h> 
+#endif
+       ], [
+          return htonll(0);
+       ])
+    ], [
+      have_htonll="yes"
+      AC_DEFINE(HAVE_HTONLL, 1, [Define if the function htonll exists.])
+    ])
+AC_MSG_RESULT([$have_htonll])
+
 # Check for structures
 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
        [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
index 8c2aeae..2598036 100644 (file)
@@ -668,6 +668,7 @@ long long get_kstat_value (kstat_t *ksp, char *name)
 }
 #endif /* HAVE_LIBKSTAT */
 
+#ifndef HAVE_HTONLL
 unsigned long long ntohll (unsigned long long n)
 {
 #if BYTE_ORDER == BIG_ENDIAN
@@ -685,6 +686,7 @@ unsigned long long htonll (unsigned long long n)
        return (((unsigned long long) htonl (n)) << 32) + htonl (n >> 32);
 #endif
 } /* unsigned long long htonll */
+#endif /* HAVE_HTONLL */
 
 #if FP_LAYOUT_NEED_NOTHING
 /* Well, we need nothing.. */
index fc809f2..c0bea36 100644 (file)
@@ -236,8 +236,10 @@ int get_kstat (kstat_t **ksp_ptr, char *module, int instance, char *name);
 long long get_kstat_value (kstat_t *ksp, char *name);
 #endif
 
+#ifndef HAVE_HTONLL
 unsigned long long ntohll (unsigned long long n);
 unsigned long long htonll (unsigned long long n);
+#endif
 
 #if FP_LAYOUT_NEED_NOTHING
 # define ntohd(d) (d)
index aade476..fe2bce3 100644 (file)
@@ -575,14 +575,14 @@ static oconfig_item_t *cf_read_dir (const char *dir, int depth)
                ERROR ("configfile: malloc failed.");
                return (NULL);
        }
-       memset (root, '\0', sizeof (oconfig_item_t));
+       memset (root, 0, sizeof (oconfig_item_t));
 
        while ((de = readdir (dh)) != NULL)
        {
                char   name[1024];
                char **tmp;
 
-               if ((de->d_name[0] == '.') || (de->d_name[0] == '\0'))
+               if ((de->d_name[0] == '.') || (de->d_name[0] == 0))
                        continue;
 
                status = ssnprintf (name, sizeof (name), "%s/%s",
@@ -624,13 +624,11 @@ static oconfig_item_t *cf_read_dir (const char *dir, int depth)
                char *name = filenames[i];
 
                temp = cf_read_generic (name, depth);
-               if (temp == NULL) {
-                       int j;
-                       for (j = i; j < filenames_num; ++j)
-                               free (filenames[j]);
-                       free (filenames);
-                       oconfig_free (root);
-                       return (NULL);
+               if (temp == NULL)
+               {
+                       /* An error should already have been reported. */
+                       sfree (name);
+                       continue;
                }
 
                cf_ci_append_children (root, temp);
index 3bd6309..681b94d 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/exec.c
- * Copyright (C) 2007-2009  Florian octo Forster
+ * Copyright (C) 2007-2010  Florian octo Forster
  * Copyright (C) 2007-2009  Sebastian Harl
  * Copyright (C) 2008       Peter Holik
  *
@@ -276,6 +276,7 @@ static void set_environment (void) /* {{{ */
   setenv ("COLLECTD_HOSTNAME", buffer, /* overwrite = */ 1);
 } /* }}} void set_environment */
 
+__attribute__((noreturn))
 static void exec_child (program_list_t *pl) /* {{{ */
 {
   int status;
@@ -550,7 +551,13 @@ static void *exec_read_one (void *arg) /* {{{ */
 
   status = fork_child (pl, NULL, &fd, &fd_err);
   if (status < 0)
+  {
+    /* Reset the "running" flag */
+    pthread_mutex_lock (&pl_lock);
+    pl->flags &= ~PL_RUNNING;
+    pthread_mutex_unlock (&pl_lock);
     pthread_exit ((void *) 1);
+  }
   pl->pid = status;
 
   assert (pl->pid != 0);
@@ -806,7 +813,7 @@ static int exec_read (void) /* {{{ */
   return (0);
 } /* int exec_read }}} */
 
-static int exec_notification (const notification_t *n,
+static int exec_notification (const notification_t *n, /* {{{ */
     user_data_t __attribute__((unused)) *user_data)
 {
   program_list_t *pl;
index b332157..348591f 100644 (file)
 # include <netinet/in.h>
 # include <netinet/tcp.h>
 
+/* Hack to work around the missing define in AIX */
+#ifndef MSG_DONTWAIT
+# define MSG_DONTWAIT MSG_NONBLOCK
+#endif
+
 #define MEMCACHED_DEF_HOST "127.0.0.1"
 #define MEMCACHED_DEF_PORT "11211"
 
index 49cf657..7a8ccc6 100644 (file)
@@ -612,16 +612,22 @@ static int o_read_database (o_database_t *db) /* {{{ */
       o_report_error ("o_read_database", "OCIAttrGet", oci_error);
       return (-1);
     }
-    assert (server_handle != NULL);
 
-    connection_status = 0;
-    status = OCIAttrGet ((void *) server_handle, OCI_HTYPE_SERVER,
-        (void *) &connection_status, /* size pointer = */ NULL,
-        OCI_ATTR_SERVER_STATUS, oci_error);
-    if (status != OCI_SUCCESS)
+    if (server_handle == NULL)
     {
-      o_report_error ("o_read_database", "OCIAttrGet", oci_error);
-      return (-1);
+      connection_status = OCI_SERVER_NOT_CONNECTED;
+    }
+    else /* if (server_handle != NULL) */
+    {
+      connection_status = 0;
+      status = OCIAttrGet ((void *) server_handle, OCI_HTYPE_SERVER,
+          (void *) &connection_status, /* size pointer = */ NULL,
+          OCI_ATTR_SERVER_STATUS, oci_error);
+      if (status != OCI_SUCCESS)
+      {
+        o_report_error ("o_read_database", "OCIAttrGet", oci_error);
+        return (-1);
+      }
     }
 
     if (connection_status != OCI_SERVER_NORMAL)
index 66abb44..bf7327c 100644 (file)
@@ -173,7 +173,8 @@ dump_entry(STRUCT_ENTRY *e, const TC_HANDLE_T handle)
        t = GET_TARGET(e);
        printf("Target name: `%s' [%u]\n", t->u.user.name, t->u.target_size);
        if (strcmp(t->u.user.name, STANDARD_TARGET) == 0) {
-               int pos = *(int *)t->data;
+               const unsigned char *data = t->data;
+               int pos = *(const int *)data;
                if (pos < 0)
                        printf("verdict=%s\n",
                               pos == -NF_ACCEPT-1 ? "NF_ACCEPT"
index 276b7af..672dae1 100644 (file)
@@ -204,7 +204,8 @@ dump_entry(struct ip6t_entry *e, const ip6tc_handle_t handle)
        t = ip6t_get_target(e);
        printf("Target name: `%s' [%u]\n", t->u.user.name, t->u.target_size);
        if (strcmp(t->u.user.name, IP6T_STANDARD_TARGET) == 0) {
-               int pos = *(int *)t->data;
+               const unsigned char *data = t->data;
+               int pos = *(const int *)data;
                if (pos < 0)
                        printf("verdict=%s\n",
                               pos == -NF_ACCEPT-1 ? "NF_ACCEPT"
index 5e5fde0..8f0b0f0 100644 (file)
@@ -744,14 +744,16 @@ static void iptcc_delete_rule(struct rule_head *r)
  * to be called from specific places within the parser */
 static int __iptcc_p_del_policy(TC_HANDLE_T h, unsigned int num)
 {
+       const unsigned char *data;
+
        if (h->chain_iterator_cur) {
                /* policy rule is last rule */
                struct rule_head *pr = (struct rule_head *)
                        h->chain_iterator_cur->rules.prev;
 
                /* save verdict */
-               h->chain_iterator_cur->verdict = 
-                       *(int *)GET_TARGET(pr->entry)->data;
+               data = GET_TARGET(pr->entry)->data;
+               h->chain_iterator_cur->verdict = *(const int *)data;
 
                /* save counter and counter_map information */
                h->chain_iterator_cur->counter_map.maptype = 
@@ -1563,6 +1565,7 @@ const char *TC_GET_TARGET(const STRUCT_ENTRY *ce,
 {
        STRUCT_ENTRY *e = (STRUCT_ENTRY *)ce;
        struct rule_head *r = container_of(e, struct rule_head, entry[0]);
+       const unsigned char *data;
 
        iptc_fn = TC_GET_TARGET;
 
@@ -1576,7 +1579,8 @@ const char *TC_GET_TARGET(const STRUCT_ENTRY *ce,
                        return r->jump->name;
                        break;
                case IPTCC_R_STANDARD:
-                       spos = *(int *)GET_TARGET(e)->data;
+                       data = GET_TARGET(e)->data;
+                       spos = *(const int *)data;
                        DEBUGP("r=%p, spos=%d'\n", r, spos);
                        return standard_target_map(spos);
                        break;
index 5e176c8..f2eb0a3 100644 (file)
@@ -262,7 +262,7 @@ static void ps_list_register (const char *name, const char *regexp)
                ERROR ("processes plugin: ps_list_register: "
                                "Regular expression \"%s\" found in config "
                                "file, but support for regular expressions "
-                               "has been dispabled at compile time.",
+                               "has been disabled at compile time.",
                                regexp);
                sfree (new);
                return;