X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fwrite_prometheus.c;h=26b0b4d4eb93f6193bade94adfd560d1290a69a4;hp=9e9ed2e8a93af9238a9314dbf374da35004c0193;hb=a9e50e9e30ecde17e167e271060c8183bfcbf407;hpb=85d892df2794d992c8e3554d8990d1306f114c11 diff --git a/src/write_prometheus.c b/src/write_prometheus.c index 9e9ed2e8..26b0b4d4 100644 --- a/src/write_prometheus.c +++ b/src/write_prometheus.c @@ -59,7 +59,7 @@ static struct MHD_Daemon *httpd; static cdtime_t staleness_delta = PROMETHEUS_DEFAULT_STALENESS_DELTA; -/* Unfortunately, protoc-c doesn't export it's implementation of varint, so we +/* Unfortunately, protoc-c doesn't export its implementation of varint, so we * need to implement our own. */ static size_t varint(uint8_t buffer[static VARINT_UINT32_BYTES], uint32_t value) { @@ -764,6 +764,15 @@ static int prom_open_socket(int addrfamily) { if (fd == -1) continue; + int tmp = 1; + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp)) != 0) { + WARNING("write_prometheus: setsockopt(SO_REUSEADDR) failed: %s", + STRERRNO); + close(fd); + fd = -1; + continue; + } + if (bind(fd, ai->ai_addr, ai->ai_addrlen) != 0) { close(fd); fd = -1;