Ejemplo n.º 1
0
int init_conf(void)
{
  if (read_configuration_file()) {
    /*
     * make sure we're sane to start if the config
     * file read didn't get everything we need.
     * XXX - should any of these abort the server?
     * TODO: add warning messages
     */
    if (0 == localConf.name || 0 == localConf.numeric)
      return 0;
    if (conf_error)
      return 0;

    if (0 == localConf.location1)
      DupString(localConf.location1, "");
    if (0 == localConf.location2)
      DupString(localConf.location2, "");
    if (0 == localConf.contact)
      DupString(localConf.contact, "");

    return 1;
  }
  return 0;
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: yystju/lidar
int start(int is_daemon) {
    debug("[START]>>\n");
    
    //Init...
    
    if(is_daemon) {
        init_deamon_process();
    }
    
    int cpu_core_count = (int)sysconf(_SC_NPROCESSORS_CONF);
    
    debug("cpu_core_count = %d\n", cpu_core_count);
    
    Configuration * configurations = read_configuration_file("./main.ini", 10);
    
    const char * repo_root = (const char *)get_configuration(configurations, "repository.root");
    
    debug("repo_root : %s\n", repo_root);
    
    REPOSITORY * repo = repository_init(repo_root);
    
    REPO_ITEM * item = repository_new_item(repo);
    
    debug("item : %s\n", item->uuid);
    
    FILE * fp_lidar_2368 = repository_open_write_file(item, "lidar.raw");
    FILE * fp_lidar_8308 = repository_open_write_file(item, "sync.raw");
    FILE * fp_ins = repository_open_write_file(item, "ins.bin");
    
    debug("fp_lidar_2368 : %p\n", fp_lidar_2368);
    debug("fp_lidar_8308 : %p\n", fp_lidar_8308);
    debug("fp_ins : %p\n", fp_ins);
    
    //Start processing threads.
    
//  pthread_t main_thread_handler = pthread_self();
	pthread_t xsens_thread_handler;
	
	pthread_t lidar_10110_thread_handler;
    pthread_t lidar_2368_thread_handler;
    pthread_t lidar_8308_thread_handler;
	
	XsensThreadData xsensThreadData;
	xsensThreadData.configurations = configurations;
	xsensThreadData.fp = fp_ins;
	
	LiDAR10110ThreadData lidar10110ThreadData;
	lidar10110ThreadData.configurations = configurations;
	
	pthread_create(&xsens_thread_handler, NULL, xsenThread, (void *)(&xsensThreadData));
	bind_thread_cpu(xsens_thread_handler, cpu_core_count - 4);
	
	pthread_create(&lidar_10110_thread_handler, NULL, lidar10110Thread, (void *)&lidar10110ThreadData);
	bind_thread_cpu(lidar_10110_thread_handler, cpu_core_count - 1);
	
	pthread_create(&lidar_2368_thread_handler, NULL, lidar2368Thread, (void *)fp_lidar_2368);
	bind_thread_cpu(lidar_2368_thread_handler, cpu_core_count - 2);
	
	pthread_create(&lidar_8308_thread_handler, NULL, lidar8308Thread, (void *)fp_lidar_8308);
	bind_thread_cpu(lidar_8308_thread_handler, cpu_core_count - 3);
	
	debug("Waiting for any key...\n");
	
	if(!is_daemon) {
    	fputs("Press any key...", stdout);
    	fgetc(stdin);
    	
    	done = 1;
    	
    	debug("Key has been pressed.\n");
    	debug("Start to dispose...\n");
	} else {
	    signal(SIGQUIT, daemon_exit_handler);
	}
	
	pthread_join(lidar_2368_thread_handler, (void *)NULL);
	pthread_join(lidar_8308_thread_handler, (void *)NULL);
	pthread_join(xsens_thread_handler, (void *)NULL);
 	pthread_join(lidar_10110_thread_handler, (void *)NULL);
	
	//Dispose...
    
    fclose(fp_lidar_8308);
    fclose(fp_lidar_2368);
    fclose(fp_ins);
    
    repository_close_item(item);
    
    repository_dispose(repo);
    
    dispose_configuration(configurations);
    
    pthread_exit(NULL);
    
    debug("[START]<<\n");
    
    return 0;
}
Ejemplo n.º 3
0
/** Reload the configuration file.
 * @param cptr Client that requested rehash (if a signal, &me).
 * @param sig Type of rehash (0 = oper-requested, 1 = signal, 2 =
 *   oper-requested but do not restart resolver)
 * @return CPTR_KILLED if any client was K/G-lined because of the
 * rehash; otherwise 0.
 */
int rehash(struct Client *cptr, int sig)
{
  struct ConfItem** tmp = &GlobalConfList;
  struct ConfItem*  tmp2;
  struct Client*    acptr;
  int               i;
  int               ret = 0;
  int               found_g = 0;

  if (1 == sig)
    sendto_opmask_butone(0, SNO_OLDSNO,
                         "Got signal SIGHUP, reloading ircd conf. file");

  while ((tmp2 = *tmp)) {
    if (tmp2->clients) {
      /*
       * Configuration entry is still in use by some
       * local clients, cannot delete it--mark it so
       * that it will be deleted when the last client
       * exits...
       */
      if (CONF_CLIENT == (tmp2->status & CONF_CLIENT))
        tmp = &tmp2->next;
      else {
        *tmp = tmp2->next;
        tmp2->next = 0;
      }
      tmp2->status |= CONF_ILLEGAL;
    }
    else {
      *tmp = tmp2->next;
      free_conf(tmp2);
    }
  }
  conf_erase_crule_list();
  conf_erase_deny_list();
  conf_erase_webirc_list();
  conf_erase_shost_list();
  conf_erase_except_list();
  motd_clear();

  /*
   * delete the juped nicks list
   */
  clearNickJupes();

  clear_quarantines();

  class_mark_delete();
  mark_listeners_closing();
  auth_mark_closing();
  close_mappings();

  read_configuration_file();

  if (sig != 2)
    restart_resolver();

  log_reopen(); /* reopen log files */

  auth_close_unused();
  close_listeners();
  class_delete_marked();         /* unless it fails */

  /*
   * Flush out deleted I and P lines although still in use.
   */
  for (tmp = &GlobalConfList; (tmp2 = *tmp);) {
    if (CONF_ILLEGAL == (tmp2->status & CONF_ILLEGAL)) {
      *tmp = tmp2->next;
      tmp2->next = NULL;
      if (!tmp2->clients)
        free_conf(tmp2);
    }
    else
      tmp = &tmp2->next;
  }

  for (i = 0; i <= HighestFd; i++) {
    if ((acptr = LocalClientArray[i])) {
      assert(!IsMe(acptr));
      if (IsServer(acptr))
        det_confs_butmask(acptr, ~(CONF_UWORLD | CONF_ILLEGAL));
      /* Because admin's are getting so uppity about people managing to
       * get past K/G's etc, we'll "fix" the bug by actually explaining
       * whats going on.
       */
      if ((found_g = find_kill(acptr))) {
        sendto_opmask_butone(0, found_g > -1 ? SNO_GLINE : SNO_OPERKILL,
                             found_g == -2 ? "G-line active for %s%s" :
                             (found_g == -3 ? "Z-line active for %s%s" :
                             "K-line active for %s%s"),
                             IsUnknown(acptr) ? "Unregistered Client ":"",
                             get_client_name(acptr, SHOW_IP));
        if (exit_client(cptr, acptr, &me, found_g == -2 ? "G-lined" :
            (found_g == -3 ? "Z-lined" : "K-lined")) == CPTR_KILLED)
          ret = CPTR_KILLED;
      }
    }
  }

  attach_conf_uworld(&me);

  geoip_init();

  auth_send_event("rehash", NULL);

  return ret;
}