Permalink
Browse files

Reduce CPU utilisation of gmond running in deaf mode

TCP thread should only poll every 100ms and should not start
at all if the gmond is configured to be deaf. Fixes #85.
  • Loading branch information...
1 parent 0ae75b6 commit c65f93324c4d6862e53dfefaa8c1da07980230fb @satterly satterly committed Mar 19, 2013
Showing with 11 additions and 16 deletions.
  1. +11 −16 gmond/gmond.c
View
27 gmond/gmond.c
@@ -3181,22 +3181,14 @@ void sig_handler(int i)
static void* APR_THREAD_FUNC tcp_listener(apr_thread_t *thd, void *data)
{
apr_time_t now;
- apr_interval_time_t wait = 1000;
+ apr_interval_time_t wait = 100 * 1000; // 100ms
debug_msg("[tcp] Starting TCP listener thread...");
for(;!done;)
{
- if(!deaf)
- {
- now = apr_time_now();
- /* Pull in incoming data */
- poll_tcp_listen_channels(wait, now);
- }
- else
- {
- apr_sleep( wait );
- }
-
+ now = apr_time_now();
+ /* Pull in incoming data */
+ poll_tcp_listen_channels(wait, now);
}
apr_thread_exit(thd, APR_SUCCESS);
@@ -3326,11 +3318,14 @@ main ( int argc, char *argv[] )
udp_last_heard = last_cleanup = next_collection = now = apr_time_now();
/* Create TCP listener thread */
- apr_thread_t *thread;
- if (apr_thread_create(&thread, NULL, tcp_listener, NULL, global_context) != APR_SUCCESS)
+ if(!deaf)
{
- err_msg("Failed to create TCP listener thread. Exiting.\n");
- exit(1);
+ apr_thread_t *thread;
+ if (apr_thread_create(&thread, NULL, tcp_listener, NULL, global_context) != APR_SUCCESS)
+ {
+ err_msg("Failed to create TCP listener thread. Exiting.\n");
+ exit(1);
+ }
}
/* Loop */

0 comments on commit c65f933

Please sign in to comment.