summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 917c18f)
raw | patch | inline | side by side (parent: 917c18f)
author | Florian Forster <octo@collectd.org> | |
Wed, 16 Jan 2013 20:50:37 +0000 (21:50 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 16 Jan 2013 20:53:36 +0000 (21:53 +0100) |
Don't warn when connecting to some address fails. The system could, for
example, not have any IPv6 connectivity but the address record also
includes an IPv6 address. In this case a connect(2) call will fail but
this is not a problem.
Due to the new locking one of the concurrency checks was made redundant.
example, not have any IPv6 connectivity but the address record also
includes an IPv6 address. In this case a connect(2) call will fail but
this is not a problem.
Due to the new locking one of the concurrency checks was made redundant.
src/riemann.c | patch | blob | history |
diff --git a/src/riemann.c b/src/riemann.c
index 4af77b43f3f8a713f66c8806f747e4da54749935..c18442996eebd74eedecafa727d92d294c55c2f2 100644 (file)
--- a/src/riemann.c
+++ b/src/riemann.c
memset(&service, 0, sizeof(service));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
+#ifdef AI_ADDRCONFIG
+ hints.ai_flags |= AI_ADDRCONFIG;
+#endif
assert (host->node != NULL);
service = (host->service != NULL) ? host->service : RIEMANN_PORT;
return -1;
}
+ host->s = -1;
for (ai = res; ai != NULL; ai = ai->ai_next) {
- /*
- * check if another thread did not already succesfully connect
- */
- if (host->flags & F_CONNECT) {
- freeaddrinfo(res);
- return 0;
- }
-
if ((host->s = socket(ai->ai_family,
ai->ai_socktype,
ai->ai_protocol)) == -1) {
- WARNING("riemann_connect: could not open socket");
- freeaddrinfo(res);
- return -1;
+ continue;
}
if (connect(host->s, ai->ai_addr, ai->ai_addrlen) != 0) {
close(host->s);
- host->flags |= ~F_CONNECT;
- freeaddrinfo(res);
- return -1;
+ host->s = -1;
+ continue;
}
+
host->flags |= F_CONNECT;
- DEBUG("riemann plugin: got a succesful connection for: %s",
- host->node);
+ DEBUG("riemann plugin: got a succesful connection for: %s:%s",
+ host->node, service);
break;
}
freeaddrinfo(res);
- if (ai == NULL) {
- WARNING("riemann_connect: no suitable hosts found");
+
+ if (host->s < 0) {
+ WARNING("riemann plugin: Unable to connect to Riemann at %s:%s",
+ host->node, service);
return -1;
}
-
return 0;
}