Exemplo n.º 1
0
static void
reset_all_list(void)
{
	reset_list(&filetypes);
	reset_list(&xfiletypes);
	reset_list(&fileviewers);

	reset_list_head(&active_filetypes);
}
Exemplo n.º 2
0
int			run_serveur(t_serv *serv)
{
  t_user		*user_list;
  fd_set		readfd;
  int			max;
  int			socks;
  char			*buff;

  max = serv->s;
  user_list = NULL;
  if ((buff = malloc(4096 * sizeof(char))) == NULL)
    return (EXIT_FAILURE);
  while (1)
    {
      reset_list(&readfd, user_list, serv, max);
      if (FD_ISSET(serv->s, &readfd))
	{
	  accept_connect(&socks, serv);
	  if (read_client(socks, buff) != 0)
	    {
	      client_connexion(&max, socks, &readfd);
	      add_user(&user_list, DEFAULT_USER, socks, NULL);
	    }
	}
      else
	send_rcv(&user_list, &readfd);
    }
}
Exemplo n.º 3
0
static struct dist_node *find_next(struct dist_list *list, int etotal, char **exceptions)
{
	struct dist_node *np, *match = NULL;
	int x = 0, mx = 0;
	int matches = 0, loops = 0;

	for (;;) {
	top:
		
		if (++loops > 1000) {
			break;
		}

		x = 0;
		if (list->last >= list->node_count) {
			list->last = -1;
		}
		match = NULL;
		matches = 0;
		for (np = list->nodes; np; np = np->next) {
			if (np->cur_weight < list->target_weight) {
				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "%s %d/%d\n", np->name, np->cur_weight, list->target_weight);
				matches++;
				if (!match && x > list->last) {
					match = np;
					mx = x;
				}
			}
			x++;
		}

		if (match) {
			int i;
			
			match->cur_weight++;
			list->lastnode = match;
			list->last = mx;

			for(i = 0; i < etotal; i++) {
				if (!strcmp(match->name, exceptions[i])) {
					if (matches == 1) {
						reset_list(list);
					}
					goto top;
				}
			}
			

			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Choose %s\n", match->name);
			return match;
		}

		if (matches) {
			list->last = -1;
		} else {
			reset_list(list);
		}

	}
	
	return NULL;
}
Exemplo n.º 4
0
void
reset_fileviewers(void)
{
	reset_list(&fileviewers, &cfg.fileviewers_num);
}
Exemplo n.º 5
0
void
reset_xfiletypes(void)
{
	reset_list(&xfiletypes, &cfg.xfiletypes_num);
}
Exemplo n.º 6
0
void
reset_filetypes(void)
{
	reset_list(&filetypes, &cfg.filetypes_num);
	reset_list(&all_filetypes, &nfiletypes);
}