From 94c4cad8053d0a0cec77fefeccaaa70d75573e1a Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 5 Oct 2017 20:17:21 +0200 Subject: [PATCH] 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* --- src/write_prometheus.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 -- 2.30.2