X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fgps.c;h=4d65176836b24946e135a2112d7cfea147236aa4;hp=a4b3e2e73e0d00bca199f63b34d694cdf50ad5d1;hb=48efd3deb4c9139fd060ff3d289896e9031bcc7c;hpb=e56c1e570ff8d4e8fe732f9d74f11217479fdd7b diff --git a/src/gps.c b/src/gps.c index a4b3e2e7..4d651768 100644 --- a/src/gps.c +++ b/src/gps.c @@ -26,10 +26,10 @@ * Marc Fournier **/ -#include "common.h" +#include "collectd.h" #include "plugin.h" +#include "utils/common/common.h" #include "utils_time.h" -#include "collectd.h" #define CGPS_TRUE 1 #define CGPS_FALSE 0 @@ -80,7 +80,7 @@ static int cgps_thread_pause(cdtime_t pTime) { int ret = !cgps_thread_shutdown; - pthread_mutex_lock(&cgps_thread_lock); + pthread_mutex_unlock(&cgps_thread_lock); return ret; } @@ -141,7 +141,12 @@ static void *cgps_thread(void *pData) { continue; } - if (gps_read(&gpsd_conn) == -1) { +#if GPSD_API_MAJOR_VERSION > 6 + if (gps_read(&gpsd_conn, NULL, 0) == -1) +#else + if (gps_read(&gpsd_conn) == -1) +#endif + { WARNING("gps plugin: incorrect data! (err_count: %d)", err_count); err_count++; @@ -226,7 +231,7 @@ static int cgps_read(void) { cgps_submit("satellites", data_copy.sats_used, "used"); cgps_submit("satellites", data_copy.sats_visible, "visible"); - return (0); + return 0; } /** @@ -262,7 +267,7 @@ static int cgps_config(oconfig_item_t *ci) { cgps_config_data.timeout = CGPS_DEFAULT_TIMEOUT; } - return (0); + return 0; } /** @@ -286,10 +291,10 @@ static int cgps_init(void) { plugin_thread_create(&cgps_thread_id, NULL, cgps_thread, NULL, "gps"); if (status != 0) { ERROR("gps plugin: pthread_create() failed."); - return (-1); + return -1; } - return (0); + return 0; } /** @@ -307,7 +312,6 @@ static int cgps_shutdown(void) { free(res); // Clean mutex: - pthread_mutex_unlock(&cgps_thread_lock); pthread_mutex_destroy(&cgps_thread_lock); pthread_mutex_unlock(&cgps_data_lock); pthread_mutex_destroy(&cgps_data_lock); @@ -315,7 +319,7 @@ static int cgps_shutdown(void) { sfree(cgps_config_data.port); sfree(cgps_config_data.host); - return (0); + return 0; } /**