From: Florian Forster Date: Fri, 16 Nov 2012 06:53:27 +0000 (+0100) Subject: Merge branch 'sh/plugin_interval' X-Git-Tag: collectd-5.2.0~20 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6d85a198dd90fb5af963ad847d9dbff7b8025c46;p=collectd.git Merge branch 'sh/plugin_interval' Conflicts: src/amqp.c src/exec.c src/memcached.c src/unixsock.c --- 6d85a198dd90fb5af963ad847d9dbff7b8025c46 diff --cc src/amqp.c index c9e46c45,db657916..9c8c6e53 --- a/src/amqp.c +++ b/src/amqp.c @@@ -607,25 -552,21 +609,25 @@@ static void *camqp_subscribe_thread (vo status = camqp_connect (conf); if (status != 0) { + struct timespec ts_interval; ERROR ("amqp plugin: camqp_connect failed. " "Will sleep for %.3f seconds.", - CDTIME_T_TO_DOUBLE (interval_g)); - CDTIME_T_TO_TIMESPEC (interval_g, &ts_interval); + CDTIME_T_TO_DOUBLE (interval)); - sleep (interval); ++ CDTIME_T_TO_TIMESPEC (interval, &ts_interval); + nanosleep (&ts_interval, /* remaining = */ NULL); continue; } status = amqp_simple_wait_frame (conf->connection, &frame); if (status < 0) { + struct timespec ts_interval; ERROR ("amqp plugin: amqp_simple_wait_frame failed. " "Will sleep for %.3f seconds.", - CDTIME_T_TO_DOUBLE (interval_g)); + CDTIME_T_TO_DOUBLE (interval)); camqp_close_connection (conf); - CDTIME_T_TO_TIMESPEC (interval_g, &ts_interval); - sleep (interval); ++ CDTIME_T_TO_TIMESPEC (interval, &ts_interval); + nanosleep (&ts_interval, /* remaining = */ NULL); continue; } diff --cc src/disk.c index 375583c4,fde0dcde..3728d556 --- a/src/disk.c +++ b/src/disk.c @@@ -248,16 -235,6 +248,17 @@@ static void disk_submit (const char *pl plugin_dispatch_values (&vl); } /* void disk_submit */ +#if KERNEL_LINUX +static counter_t disk_calc_time_incr (counter_t delta_time, counter_t delta_ops) +{ ++ double interval = CDTIME_T_TO_DOUBLE (plugin_get_interval ()); + double avg_time = ((double) delta_time) / ((double) delta_ops); - double avg_time_incr = CDTIME_T_TO_DOUBLE (interval_g) * avg_time; ++ double avg_time_incr = interval * avg_time; + + return ((counter_t) (avg_time_incr + .5)); +} +#endif + #if HAVE_IOKIT_IOKITLIB_H static signed long long dict_get_value (CFDictionaryRef dict, const char *key) { diff --cc src/exec.c index 0e807c75,da6e367d..14d288f1 --- a/src/exec.c +++ b/src/exec.c @@@ -826,8 -814,7 +827,8 @@@ static int exec_read (void) /* {{{ * pthread_attr_init (&attr); pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - pthread_create (&t, &attr, exec_read_one, (void *) pl); + plugin_thread_create (&t, &attr, exec_read_one, (void *) pl); + pthread_attr_destroy (&attr); } /* for (pl) */ return (0); @@@ -870,8 -857,7 +871,8 @@@ static int exec_notification (const not pthread_attr_init (&attr); pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - pthread_create (&t, &attr, exec_notification_one, (void *) pln); + plugin_thread_create (&t, &attr, exec_notification_one, (void *) pln); + pthread_attr_destroy (&attr); } /* for (pl) */ return (0); diff --cc src/postgresql.c index 675505bb,953bcd83..a72109ae --- a/src/postgresql.c +++ b/src/postgresql.c @@@ -345,12 -337,10 +345,13 @@@ static PGresult *c_psql_exec_query_para case C_PSQL_PARAM_INTERVAL: ssnprintf (interval, sizeof (interval), "%.3f", (db->interval > 0) - ? CDTIME_T_TO_DOUBLE (db->interval) : interval_g); + ? CDTIME_T_TO_DOUBLE (db->interval) + : plugin_get_interval ()); params[i] = interval; break; + case C_PSQL_PARAM_INSTANCE: + params[i] = db->instance; + break; default: assert (0); } diff --cc src/unixsock.c index 0dc7d659,337978df..2c1665fc --- a/src/unixsock.c +++ b/src/unixsock.c @@@ -363,7 -352,11 +363,8 @@@ static void *us_server_thread (void __a DEBUG ("Spawning child to handle connection on fd #%i", *remote_fd); - status = pthread_create (&th, &th_attr, us_handle_client, (void *) remote_fd); - pthread_attr_init (&th_attr); - pthread_attr_setdetachstate (&th_attr, PTHREAD_CREATE_DETACHED); - + status = plugin_thread_create (&th, &th_attr, + us_handle_client, (void *) remote_fd); if (status != 0) { char errbuf[1024];