
ufdbguardd.c

	The multi-threaded ufdbguardd daemon has 32 worker threads to perform
	URL verifications.  There is one thread that listens on the main socket 
	for new connections.  There is a helper thread to catch the HUP signal 
	that is used to re-read the configuration files and URL database files.
	There are 4 threads to detect proxy tunnels.

	initialise_readonly_db_in_memory();
	pthread_create( io_handler );
	pthread_create( hup_signal_handler );
	for (i = 0; i < 4; i++)
		pthread_create( tunnel_verifier );
	for (i = 0; i < 32; i++)
		pthread_create( worker );
        
	pthread_join( io_handler );
	exit( 0 );


	io_handler()
	{
		sock = open_server_socket();
		while (newfd = accept(sock))
		{
			push_fd( newfd );
	        }
        }

	worker()
	{
		while (1)
		{
		   fd = pop_fd();
		   while (readline(fd,line) > 0)
		   {
		       parseline( line );
		       res = lookup( line );
		       send_result( fd, res );
		   }
		   close( fd );
	        }
        }

	lookup( line )
	{
	   if (Reconfiguring)
	      return "";	/* OK */
	   return UFDBlookup( line );
        }

	hup_signal_handler()
	{
	   Reconfiguring = 1;
	   reload_config();
	   Reconfiguring = 0;
	}



ufdbgclient.c  

	ufdbgclient is the squid redirector and replaces ufdbGuard.
	It receives requests from squid and sends them to ufdbguardd daemon.
	The replies of ufdbguardd are forwarded to squid.

	server_sock = open_socket_with( ufdbGuardDaemonSocket );
	while (1)
	{
		line = fgets( stdin );
		reply = get_reply_from_ufdb_daemon( server_sock, line );
		fputs( reply, stdout );
        }

