projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Various plugins: Use the IS_TRUE and IS_FALSE macros everywhere.
[collectd.git]
/
src
/
collectd.c
diff --git
a/src/collectd.c
b/src/collectd.c
index
57701c0
..
bc69a3b
100644
(file)
--- a/
src/collectd.c
+++ b/
src/collectd.c
@@
-47,7
+47,7
@@
kstat_ctl_t *kc;
static int loop = 0;
static int loop = 0;
-static void *do_flush (void *arg)
+static void *do_flush (void
__attribute__((unused))
*arg)
{
INFO ("Flushing all data.");
plugin_flush (NULL, -1, NULL);
{
INFO ("Flushing all data.");
plugin_flush (NULL, -1, NULL);
@@
-56,17
+56,17
@@
static void *do_flush (void *arg)
return NULL;
}
return NULL;
}
-static void sig_int_handler (int signal)
+static void sig_int_handler (int
__attribute__((unused))
signal)
{
loop++;
}
{
loop++;
}
-static void sig_term_handler (int signal)
+static void sig_term_handler (int
__attribute__((unused))
signal)
{
loop++;
}
{
loop++;
}
-static void sig_usr1_handler (int signal)
+static void sig_usr1_handler (int
__attribute__((unused))
signal)
{
pthread_t thread;
pthread_attr_t attr;
{
pthread_t thread;
pthread_attr_t attr;
@@
-102,9
+102,7
@@
static int init_hostname (void)
}
str = global_option_get ("FQDNLookup");
}
str = global_option_get ("FQDNLookup");
- if ((strcasecmp ("false", str) == 0)
- || (strcasecmp ("no", str) == 0)
- || (strcasecmp ("off", str) == 0))
+ if (IS_FALSE (str))
return (0);
memset (&ai_hints, '\0', sizeof (ai_hints));
return (0);
memset (&ai_hints, '\0', sizeof (ai_hints));
@@
-301,6
+299,7
@@
static int do_loop (void)
{
struct timeval tv_now;
struct timeval tv_next;
{
struct timeval tv_now;
struct timeval tv_next;
+ struct timeval tv_wait;
struct timespec ts_wait;
while (loop == 0)
struct timespec ts_wait;
while (loop == 0)
@@
-331,14
+330,17
@@
static int do_loop (void)
return (-1);
}
return (-1);
}
- if (timeval_
sub_timespec (&tv_next, &tv_now, &ts_wait) !
= 0)
+ if (timeval_
cmp (tv_next, tv_now, &tv_wait) <
= 0)
{
{
- WARNING ("Not sleeping because "
- "
`timeval_sub_timespec' returned "
-
"non-zero!"
);
+ WARNING ("Not sleeping because
the next interval is
"
+ "
%i.%06i seconds in the past!",
+
(int) tv_wait.tv_sec, (int) tv_wait.tv_usec
);
continue;
}
continue;
}
+ ts_wait.tv_sec = tv_wait.tv_sec;
+ ts_wait.tv_nsec = (long) (1000 * tv_wait.tv_usec);
+
while ((loop == 0) && (nanosleep (&ts_wait, &ts_wait) == -1))
{
if (errno != EINTR)
while ((loop == 0) && (nanosleep (&ts_wait, &ts_wait) == -1))
{
if (errno != EINTR)
@@
-406,6
+408,7
@@
int main (int argc, char **argv)
pid_t pid;
int daemonize = 1;
#endif
pid_t pid;
int daemonize = 1;
#endif
+ int exit_status = 0;
/* read options */
while (1)
/* read options */
while (1)
@@
-589,16
+592,20
@@
int main (int argc, char **argv)
* run the actual loops
*/
do_init ();
* run the actual loops
*/
do_init ();
+
if (test_readall)
{
if (test_readall)
{
- if (plugin_read_all_once ())
-
return (1)
;
+ if (plugin_read_all_once ()
!= 0
)
+
exit_status = 1
;
}
else
}
else
+ {
+ INFO ("Initialization complete, entering read-loop.");
do_loop ();
do_loop ();
+ }
/* close syslog */
/* close syslog */
- INFO ("Exiting normally");
+ INFO ("Exiting normally
.
");
do_shutdown ();
do_shutdown ();
@@
-607,5
+614,5
@@
int main (int argc, char **argv)
pidfile_remove ();
#endif /* COLLECT_DAEMON */
pidfile_remove ();
#endif /* COLLECT_DAEMON */
- return (
0
);
+ return (
exit_status
);
} /* int main */
} /* int main */