Пример #1
0
void module_start_staging(void)
{
    IndexTable* src = &module_tables[erts_active_code_ix()];
    IndexTable* dst = &module_tables[erts_staging_code_ix()];
    Module* src_mod;
    Module* dst_mod;
    int i, oldsz, newsz;

    ASSERT(dbg_load_code_ix == -1);
    ASSERT(dst->entries <= src->entries);

    /*
     * Make sure our existing modules are up-to-date
     */
    for (i = 0; i < dst->entries; i++) {
	src_mod = (Module*) erts_index_lookup(src, i);
	dst_mod = (Module*) erts_index_lookup(dst, i);
	ASSERT(src_mod->module == dst_mod->module);
        copy_module(dst_mod, src_mod);
    }

    /*
     * Copy all new modules from active table
     */
    oldsz = index_table_sz(dst);
    for (i = dst->entries; i < src->entries; i++) {
	src_mod = (Module*) erts_index_lookup(src, i);
	dst_mod = (Module*) index_put_entry(dst, src_mod);
	ASSERT(dst_mod != src_mod);

        copy_module(dst_mod, src_mod);
    }
    newsz = index_table_sz(dst);
    erts_atomic_add_nob(&tot_module_bytes, (newsz - oldsz));

    entries_at_start_staging = dst->entries;
    IF_DEBUG(dbg_load_code_ix = erts_staging_code_ix());
}
Пример #2
0
/*
 * -- configure
 *
 * do a first pass of the command line parameters to find all
 * configuration files. the options in those files are processed
 * before any other command line parameter. command line will
 * overwrite any other configuration, as well as the last config
 * file will overwrite previous config files.
 *
 */
void
configure(struct _como * m, int argc, char ** argv)
{
    cli_args_t cli_args;
    int config_file_exists;
    int c, i, j;
    DIR *d;
    
    if (m->cli_args.done_flag == 0) {
	parse_cmdline(&cli_args, argc, argv);

	if (cli_args.logflags != -1) {
	    m->logflags = cli_args.logflags;
	    m->cli_args.logflags_set = 1;
	}
	if (cli_args.dbdir != NULL) {
	    safe_dup(&m->dbdir, cli_args.dbdir);
	    m->cli_args.dbdir_set = 1;
	}
	if (cli_args.libdir != NULL) {
	    safe_dup(&m->libdir, cli_args.libdir);
	    m->cli_args.libdir_set = 1;
	}
	if (cli_args.query_port != -1) {
	    m->node->query_port = cli_args.query_port;
	    m->cli_args.query_port_set = 1;
	}
	if (cli_args.mem_size != 0) {
	    m->mem_size = cli_args.mem_size;
	    m->cli_args.mem_size_set = 1;
	}
	m->exit_when_done = cli_args.exit_when_done;
    }
    
    m->runmode = cli_args.runmode;
    m->inline_fd = (m->runmode == RUNMODE_INLINE) ? 1 /* stdout */ : -1; 
    
    m->debug = cli_args.debug;

    /*
     * build list of config files
     */
    config_file_exists = 0;
    for (c = 0; c < cli_args.cfg_files_count; c++) {
	config_file_exists = 1;
	parse_cfgfile(m, cli_args.cfg_files[c]);
    }
    
    if (!config_file_exists && m->runmode != RUNMODE_INLINE) 
        parse_cfgfile(m, DEFAULT_CFGFILE);	/* add default config file */

    if (m->runmode == RUNMODE_INLINE) {
	char *conf_argv[2];
	
	m->exit_when_done = 1;
	
    	if (cli_args.sniffer != NULL) {
	    add_sniffer(m, cli_args.sniffer, NULL, NULL);
    	}
    	
	/* prepare the arguments for do_config() */
	conf_argv[0] = "module";
	conf_argv[1] = cli_args.module;
	do_config(m, 2, conf_argv);

	if (cli_args.module_args != NULL) {
	    conf_argv[0] = "args";
	    conf_argv[1] = cli_args.module_args;
	    do_config(m, 2, conf_argv);
	}
	
	if (cli_args.filter != NULL) {
	    conf_argv[0] = "filter";
	    conf_argv[1] = cli_args.filter;
	    do_config(m, 2, conf_argv);
	}
	
	conf_argv[0] = "end";
	do_config(m, 1, conf_argv);
    }

    /* 
     * now look into the virtual nodes and replicate
     * all modules that have been found in the config file(s)
     * 
     * these new modules will have the same name but will be 
     * running the additional filter associated with the virtual 
     * node and save data in the virtual node dbdir.  
     * 
     * XXX all virtual nodes will be running on demand and 
     *     the source is defined in the configuration (or assumed to 
     *     be a trace module). later there shouldn't be a need 
     *     for defining the source module anyway...
     *
     */
    for (i = 0, j = m->module_last; i <= j; i++) { 
	module_t * orig; 
	int node_id; 

	orig = &m->modules[i]; 
	for (node_id = 1; node_id < m->node_count; node_id++) { 
	    module_t * mdl; 
	    char * nm; 

	    /* create a new module and copy it from  new module */
	    mdl = copy_module(m, orig, node_id, -1, m->node[node_id].args);
	    mdl->running = RUNNING_ON_DEMAND; 
	    
	    /* append node id to module's output file */
	    asprintf(&nm, "%s-%d", mdl->output, mdl->node); 
	    safe_dup(&mdl->output, nm); 
	    free(nm); 
	    
	    /* add the node filter to the module filter */
	    if (m->node[node_id].filter_str) {
		char * flt;
		if (!strcmp(mdl->filter_str, "all"))
		    asprintf(&flt, "%s", m->node[node_id].filter_str);
		else 
		    asprintf(&flt,"(%s) and (%s)", 
			m->node[node_id].filter_str, mdl->filter_str);
		mdl->filter_str = flt; /* FIXME: possible leak */
	    } 

	    /* add the node arguments to the module arguments */ 
	    if (m->node[node_id].args) { 
		int k; 

	 	for (k = 0; m->node[node_id].args[k]; k++) {
		    /* 
		     * XXX we copy one argument at a time to avoid 
		     *     having to count them first. FIX THIS
		     */ 
		    mdl->args = 
			copy_args(mdl->args, &m->node[node_id].args[k], 1); 
		}
	    } 

            logmsg(LOGUI, "... module%s %s [%d][%d] ",
                   (mdl->running == RUNNING_ON_DEMAND) ? " on-demand" : "",
                   mdl->name, mdl->node, mdl->priority);
            logmsg(LOGUI, " filter %s; out %s (%uMB)\n",
                   mdl->filter_str, mdl->output, mdl->streamsize/(1024*1024));
            if (mdl->description != NULL)
                logmsg(LOGUI, "    -- %s\n", mdl->description);
	}
    }

    /* 
     * open the dbdir for all nodes (virtual ones included) 
     */
    if (m->runmode == RUNMODE_NORMAL) {
	if (m->dbdir == NULL)
	    panicx("missing db-path");
	d = opendir(m->dbdir);
	if (d == NULL) 
	    createdir(m->dbdir); 
	else 
	    closedir(d);
    }

    /*
     * process the AS file
     */

    asn_readfile(m->asnfile);
}
Пример #3
0
/*
 * -- configure
 *
 * do a first pass of the command line parameters to find all
 * configuration files. the options in those files are processed
 * before any other command line parameter. command line will
 * overwrite any other configuration, as well as the last config
 * file will overwrite previous config files.
 *
 */
void
configure(struct _como * m, int argc, char ** argv)
{
    static cli_args_t cli_args;
    int config_file_exists;
    int c, i, j;
    DIR *d;
    
    if (cli_args.done == 0) {
	parse_cmdline(&cli_args, argc, argv);
    }
    
    m->running = cli_args.running;

    /*
     * build list of config files
     */
    config_file_exists = 0;
    for (c = 0; c < cli_args.cfg_files_count; c++) {
	config_file_exists = 1;
	parse_cfgfile(m, cli_args.cfg_files[c]);
    }
    
    if (!config_file_exists && m->running == NORMAL) 
        parse_cfgfile(m, DEFAULT_CFGFILE);	/* add default config file */

    /* use cli args to override cfg file settings */
    if (cli_args.basedir != NULL)
	safe_dup(&m->basedir, cli_args.basedir);
    if (cli_args.libdir != NULL)
	safe_dup(&m->libdir, cli_args.libdir);
    if (cli_args.query_port != -1)
	m->node->query_port = cli_args.query_port;
    if (cli_args.mem_size != 0)
	m->mem_size = cli_args.mem_size;
    if (cli_args.logflags != -1)
	m->logflags = cli_args.logflags;
    m->debug = cli_args.debug;
    
    if (m->running == INLINE) {
	char *conf_argv[2];
	
    	if (cli_args.sniffer != NULL) {
	    add_sniffer(m, cli_args.sniffer, NULL, NULL);
    	}
    	
	/* prepare the arguments for do_config() */
	conf_argv[0] = "module";
	conf_argv[1] = cli_args.module;
	do_config(m, 2, conf_argv);

	if (cli_args.module_args != NULL) {
	    conf_argv[0] = "args";
	    conf_argv[1] = cli_args.module_args;
	    do_config(m, 2, conf_argv);
	}
	
	if (cli_args.filter != NULL) {
	    conf_argv[0] = "filter";
	    conf_argv[1] = cli_args.filter;
	    do_config(m, 2, conf_argv);
	}
	
	conf_argv[0] = "end";
	do_config(m, 1, conf_argv);
    }

    /* 
     * now look into the virtual nodes and replicate
     * all modules that have been found in the config file(s)
     * 
     * these new modules will have the same name but will be 
     * running the additional filter associated with the virtual 
     * node and save data in the virtual node basedir.  
     */
    for (i = 0, j = m->module_last; i <= j; i++) { 
	node_t * node; 
	module_t * orig; 

	orig = &m->modules[i]; 
	for (node = m->node; node; node = node->next) { 
	    module_t * mdl; 
	    char * nm; 

	    if (node->id == 0) 
		break; 	/* master node. nothing to do */

	    /* create a new module and copy it from  new module */
	    mdl = copy_module(m, orig, node->id, -1, NULL);
	    
	    /* append node id to module's output file */
	    asprintf(&nm, "%s-%d", mdl->output, mdl->node); 
	    safe_dup(&mdl->output, nm); 
	    free(nm); 
	    
	    /* add the node filter to the module filter */
	    if (node->filter_str) {
		char * flt;
		if (!strcmp(mdl->filter_str, "all"))
		    asprintf(&flt, "%s", node->filter_str);
		else 
		    asprintf(&flt,"(%s) and (%s)", 
				node->filter_str, mdl->filter_str);
		mdl->filter_str = flt; /* FIXME: possible leak */
	    } 

            logmsg(LOGUI, "... module %s [%d][%d] ",
                   mdl->name, mdl->node, mdl->priority);
            logmsg(LOGUI, " filter %s; out %s (%uMB)\n",
                   mdl->filter_str, mdl->output, mdl->streamsize/(1024*1024));
            if (mdl->description != NULL)
                logmsg(LOGUI, "    -- %s\n", mdl->description);
	}
    }

    /* 
     * open the basedir for all nodes (virtual ones included) 
     */
    if (m->basedir == NULL)
	panicx("missing basedir");
    d = opendir(m->basedir);
    if (d == NULL) 
	createdir(m->basedir); 
    else 
	closedir(d);
}