Example #1
0
void mem_check( int64_t tval, void *arg )
{
	struct rusage ru;

	getrusage( RUSAGE_SELF, &ru );

	ctl->mem->curr_kb = ru.ru_maxrss;

	if( ctl->mem->curr_kb > ctl->mem->max_kb )
		loop_end( "Memory usage exceeds configured maximum." );
}
Example #2
0
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;
}
Example #3
0
        bool analyze(float * spectrum, bool initialized) {

#ifdef DETECT_PRINT
            printf("\n");
#endif

            ++_iteration_;
            loop_start(spectrum);

            if (!initialized) {
                NBL_WARN("Channel::analyze() not calling _analyze()")
            }

            bool ret = initialized ? _analyze() : false;

            loop_end();

            return ret;
        }
Example #4
0
int			loop(t_server *server)
{
  t_client		*client;

  FD_ZERO(&server->fd_read);
  FD_ZERO(&server->fd_write);
  server->fd_max = 0;
  client = server->client;
  while (client != NULL)
    {
      if (client->type != 0)
	{
	  FD_SET(client->sock, &server->fd_read);
	  FD_SET(client->sock, &server->fd_write);
	  server->fd_max = client->sock;
	}
      client = client->next;
    }
  if (do_select(server) == 0)
    return (0);
  client = server->client;
  loop_end(server, client);
  return (1);
}