From: Florian Forster Date: Mon, 15 Mar 2010 21:40:45 +0000 (+0100) Subject: Merge branch 'collectd-4.8' into collectd-4.9 X-Git-Tag: collectd-4.9.2~8 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=9988d61c84dfff5d04ddf48f4b93f6c9449cdc41;hp=3bd6fcdfd20002eee1f1803460728449c0c98f86 Merge branch 'collectd-4.8' into collectd-4.9 Conflicts: src/exec.c --- diff --git a/.mailmap b/.mailmap index 9bb4399e..a39a1d22 100644 --- a/.mailmap +++ b/.mailmap @@ -5,4 +5,5 @@ Luboš Staněk Luboš Staněk Niki W. Waibel Sebastian Harl +Rodolphe Quiedeville diff --git a/configure.in b/configure.in index b3a7dcc8..32805063 100644 --- a/configure.in +++ b/configure.in @@ -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 +#include +#ifdef HAVE_INTTYPES_H +#include +#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.])], diff --git a/src/common.c b/src/common.c index c6a651dc..ae57c433 100644 --- a/src/common.c +++ b/src/common.c @@ -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.. */ diff --git a/src/common.h b/src/common.h index 019e8b69..7b9fa0ac 100644 --- a/src/common.h +++ b/src/common.h @@ -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) diff --git a/src/configfile.c b/src/configfile.c index b2997d64..2eea2362 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -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); diff --git a/src/exec.c b/src/exec.c index 3bd6309f..681b94d6 100644 --- a/src/exec.c +++ b/src/exec.c @@ -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; diff --git a/src/memcached.c b/src/memcached.c index b3321578..348591fd 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -38,6 +38,11 @@ # include # include +/* 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" diff --git a/src/oracle.c b/src/oracle.c index 49cf6571..7a8ccc6b 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -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) diff --git a/src/owniptc/libip4tc.c b/src/owniptc/libip4tc.c index 66abb44c..bf7327cd 100644 --- a/src/owniptc/libip4tc.c +++ b/src/owniptc/libip4tc.c @@ -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" diff --git a/src/owniptc/libip6tc.c b/src/owniptc/libip6tc.c index 276b7af8..672dae12 100644 --- a/src/owniptc/libip6tc.c +++ b/src/owniptc/libip6tc.c @@ -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" diff --git a/src/owniptc/libiptc.c b/src/owniptc/libiptc.c index 5e5fde08..8f0b0f09 100644 --- a/src/owniptc/libiptc.c +++ b/src/owniptc/libiptc.c @@ -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; diff --git a/src/processes.c b/src/processes.c index 5e176c87..f2eb0a34 100644 --- a/src/processes.c +++ b/src/processes.c @@ -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;