From: Florian Forster Date: Thu, 5 Oct 2017 18:17:21 +0000 (+0200) Subject: write_prometheus plugin: Add support for libmicrohttpd < 0.9.0. X-Git-Tag: collectd-5.8.0~1^2~13^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=94c4cad8053d0a0cec77fefeccaaa70d75573e1a;p=collectd.git write_prometheus plugin: Add support for libmicrohttpd < 0.9.0. 0.9.0 was released in July 2010, yet Precise, which we're still building for, ships 0.4.6. *sigh* --- diff --git a/src/write_prometheus.c b/src/write_prometheus.c index fe6f1cc3..21bfb54f 100644 --- a/src/write_prometheus.c +++ b/src/write_prometheus.c @@ -731,6 +731,7 @@ metric_family_get(data_set_t const *ds, value_list_t const *vl, size_t ds_index, } /* }}} */ +#if MHD_VERSION >= 0x00090000 static int prom_open_socket(int domain, struct sockaddr const *addr, socklen_t addrlen) { int fd = socket(domain, SOCK_STREAM | SOCK_CLOEXEC, 0); @@ -788,6 +789,21 @@ static struct MHD_Daemon *prom_start_daemon() { return d; } +#else /* if MHD_VERSION < 0x00090000 */ +static struct MHD_Daemon *prom_start_daemon() { + struct MHD_Daemon *d = + MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, 0, + /* MHD_AcceptPolicyCallback = */ NULL, + /* MHD_AcceptPolicyCallback arg = */ NULL, http_handler, + NULL, MHD_OPTION_END); + if (d == NULL) { + ERROR("write_prometheus plugin: MHD_start_daemon() failed."); + return NULL; + } + + return d; +} +#endif /* * collectd callbacks