Exemplo n.º 1
0
JNIEXPORT jint JNICALL
Java_OnloadExt_SaveStackName (JNIEnv* env, jclass cls)
{
	(void) env;
	(void) cls;
	return (jint) onload_stackname_save();
}
Exemplo n.º 2
0
/* A socket is created, we know its type - check if we should set a
 * new stackname, and do so.
 */
static int apply_extname(int socket_type)
{
  char name[MAX_EXTNAME_LEN];
  int ok;

  /* Need to have loaded the config from disk */
  ensure_config_loaded();

  LOG("apply_extname(%d) tid=%d", socket_type, (int)pthread_self());

  /* Find the name for this thread */
  ok = get_extname_for_thread(pthread_self(), name);
  LOG("get_extname_for_thread returned %d %s", ok, name);

  if( ok >= 0 ) {
    /* Store the current name, so we can restore it later */
    ok = onload_stackname_save();
    /* Adjust the name to account for socket type */
    alter_name_for_socket(socket_type, name);
    /* Adjust the name to account for CPU */
    alter_name_for_cpu(name);
    /* Check for 'do not accelerate' name, then set appropriate name */
    if( !strncasecmp("_", name, 2) )
      ok = onload_set_stackname(ONLOAD_THIS_THREAD, ONLOAD_SCOPE_GLOBAL,
                                ONLOAD_DONT_ACCELERATE);
    else
      ok = onload_set_stackname(ONLOAD_THIS_THREAD, ONLOAD_SCOPE_GLOBAL,
                                name);
    LOG("onload_set_stackname(\"%s\"): %d (%d)", name, ok, errno);
  }

  return ok;
}