void loop_start( void ) { // set us going ctl->run_flags |= RUN_LOOP; get_time( ); // start a timing circuit thread_throw( &loop_timer, NULL ); // and the tset/target loops // must happen before stats_start target_start( ); // throw the data submission loops stats_start( ctl->stats->stats ); stats_start( ctl->stats->adder ); stats_start( ctl->stats->gauge ); stats_start( ctl->stats->self ); // and a synthetics loop thread_throw( &synth_loop, NULL ); // throw the memory control loop thread_throw( &mem_loop, NULL ); // and gc thread_throw( &gc_loop, NULL ); // and token cleanup thread_throw( &token_loop, NULL ); // throw the data listener loop net_start_type( ctl->net->stats ); net_start_type( ctl->net->adder ); net_start_type( ctl->net->gauge ); net_start_type( ctl->net->compat ); // and now we wait for the signal to end while( ctl->run_flags & RUN_LOOP ) sleep( 1 ); }
void stats_start( ST_CFG *cf ) { int i; if( cf->enable == 0 ) { notice( "Data reporting for %s is disabled.", cf->name ); return; } // throw each of the threads for( i = 0; i < cf->threads; i++ ) thread_throw( &stats_loop, &(cf->ctls[i]) ); info( "Started %s data processing loops.", cf->name ); }
void *tcp_loop( void *arg ) { struct pollfd p; NET_PORT *n; THRD *t; HOST *h; int rv; t = (THRD *) arg; n = (NET_PORT *) t->arg; p.fd = n->sock; p.events = POLL_EVENTS; loop_mark_start( "tcp" ); while( ctl->run_flags & RUN_LOOP ) { if( ( rv = poll( &p, 1, 500 ) ) < 0 ) { if( errno != EINTR ) { err( "Poll error on %s -- %s", n->type->label, Err ); loop_end( "polling error on tcp socket" ); break; } } else if( !rv ) continue; // go get that then if( p.revents & POLL_EVENTS ) { if( ( h = tcp_get_host( p.fd, n ) ) ) thread_throw( tcp_connection, h ); } } loop_mark_done( "tcp", 0, 0 ); free( t ); return NULL; }