summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8eee594)
raw | patch | inline | side by side (parent: 8eee594)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Fri, 26 May 2017 06:46:09 +0000 (12:46 +0600) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Fri, 26 May 2017 06:46:09 +0000 (12:46 +0600) |
Implementation was broken, it doesn't reconnects as planned.
src/apcups.c | patch | blob | history |
diff --git a/src/apcups.c b/src/apcups.c
index f6ee2dbf4ca5dc4d1b9e2fc69f1a6958b4a6bb8c..7c6a47c1b97c5bf1b19ac53206de890d515897a0 100644 (file)
--- a/src/apcups.c
+++ b/src/apcups.c
char recvline[1024];
char *tokptr;
char *toksaveptr;
- _Bool retry = 1;
+ int try = 0;
int status;
#if APCMAIN
#define PRINT_VALUE(name, val) /**/
#endif
- while (retry) {
+ while (1) {
if (global_sockfd < 0) {
global_sockfd = net_open(node, service);
if (global_sockfd < 0) {
status = net_send(&global_sockfd, "status", strlen("status"));
if (status != 0) {
- /* net_send is closing the socket on error. */
+ /* net_send closes the socket on error. */
assert(global_sockfd < 0);
- if (retry) {
- retry = 0;
+ if (try == 0) {
+ try++;
count_retries++;
continue;
}
}
break;
- } /* while (retry) */
+ } /* while (1) */
/* When collectd's collection interval is larger than apcupsd's
* timeout, we would have to retry / re-connect each iteration. Try to