示例#1
0
static	void    Wackamole_init()
{
  wack_alarm(LOGIC,"Wackamole_init");

  /* Set defaults */
  Maturity_timeout.sec = 5*60;
  Maturity_timeout.usec = 0;
  Balance_timer.sec = 5*60;
  Balance_timer.usec = 0;
  Balance_rate = 1;
  Complete_balance = 0;
  Spread_retry_interval = 5;

  spread_lock = 0;

#ifdef USE_EMBEDDED_PERL
  perl_startup();
#endif

  Get_conf(File_name, &My);

  /* start up control socket */
  create_control_socket(control_socket);

  if ( Balance_rate > Num_pseudo / 2)
    Balance_rate = Num_pseudo / 2;

  if( Complete_balance )
    {
      Balance_rate = Num_pseudo / 2;
      Balance_timer.sec = 0;
    }
}
示例#2
0
文件: core.c 项目: steeve85/proxenet
int proxenet_start() 
{
	sock_t control_socket, listening_socket;
	struct sigaction saction;
	
	control_socket = listening_socket = -1;

	/* create control socket */
	control_socket = create_control_socket();
	if (control_socket < 0) {
		xlog(LOG_CRITICAL, "Cannot create control socket: %s\n", strerror(errno));
		return -1;
	}

#ifdef DEBUG
	xlog(LOG_INFO, "Control socket: %d\n", control_socket);
#endif
	
	/* create listening socket */
	listening_socket = create_bind_socket(cfg->iface, cfg->port);
	if (listening_socket < 0) {
		xlog(LOG_CRITICAL, "Cannot create bind socket: %s\n", strerror(errno));
		return -1;
	}

#ifdef DEBUG
	xlog(LOG_INFO, "Bind socket: %d\n", listening_socket);
#endif
	
	/* init everything */
	initialize_sigmask(&saction);

	plugins_list = NULL;
	proxy_state = INACTIVE;
	active_threads_bitmask = 0;
	
	/* set up plugins */
	if( proxenet_initialize_plugins_list() < 0 )
		return -1;
	
	proxenet_initialize_plugins(); // call *MUST* succeed or abort()

	/* setting request counter  */
	request_id = 0;
	get_new_request_id();
	
	/* prepare threads and start looping */
	xloop(listening_socket, control_socket);
	
	/* clean context */
	proxenet_remove_all_plugins();
	
	close_socket(listening_socket);
	close_socket(control_socket);

	unlink(CONTROL_SOCK_PATH);
	return 0;
}