Example #1
0
static gchar* _main_getStaticTLSValue(Options* options, Configuration* config, gchar* preloadArgValue) {
    /*
     * compute the actual static TLS size we need based on the libraries specified in the
     * shadow.config.xml file and our environment. this involves finding all of the plugins
     * and preloads that we need, and counting how many nodes load each of those libraries.
     */

    TLSCountingState* state = g_new0(TLSCountingState, 1);
    state->config = config;
    state->allHosts = configuration_getHostElements(config);
    state->cachedProcessTLSSize = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);

    /* for each lib, we go through each node and find each application that uses that lib */
    g_queue_foreach(state->allHosts, (GFunc)_main_countTLSHostCallback, state);

    /* now count the size required to load the global shadow preload library */
    gulong tlsSizePerLoad = _main_computePreloadLoadSize(preloadArgValue);
    if(tlsSizePerLoad == 0) {
        warning("skipping shadow global preload lib at path '%s' when computing total needed static TLS size",
                preloadArgValue);
    } else {
        state->tlsSizeTotal += tlsSizePerLoad;
    }

    /* make sure we want to use at least 1 KiB */
    if(state->tlsSizeTotal < 1024) {
        state->tlsSizeTotal = 1024;
    }

    message("finished checking TLS size required for %u hosts; used dlmopen for %lu namespaces and cache for %lu namespaces",
            state->allHosts->length, state->numCacheMisses, state->numCacheHits);

    GString* sbuf = g_string_new(NULL);
    g_string_printf(sbuf, "%lu", state->tlsSizeTotal);
    g_hash_table_destroy(state->cachedProcessTLSSize);
    g_free(state);
    return g_string_free(sbuf, FALSE);
}
Example #2
0
static void _master_registerHosts(Master* master) {
    MAGIC_ASSERT(master);
    GQueue* hosts = configuration_getHostElements(master->config);
    g_queue_foreach(hosts, (GFunc)_master_registerHostCallback, master);
}