static void JNICALL object_free(jvmtiEnv* jvmti, jlong tag) { jvmti->RawMonitorEnter(vm_death_lock); { if ( !vm_death_active ) { get_agent(jvmti)->object_free(jvmti, tag); } } jvmti->RawMonitorExit(vm_death_lock); }
static void JNICALL thread_end(jvmtiEnv *jvmti, JNIEnv *env, jthread thread) { jvmti->RawMonitorEnter(vm_death_lock); { if ( !vm_death_active ) { get_agent(jvmti)->thread_end(jvmti, env, thread); } } jvmti->RawMonitorExit(vm_death_lock); }
static void JNICALL object_free(jvmtiEnv* jvmti, jlong tag) { menter(jvmti, vm_death_lock); { if ( !vm_death_active ) { get_agent(jvmti)->object_free(jvmti, tag); } } mexit(jvmti, vm_death_lock); }
static void JNICALL thread_end(jvmtiEnv *jvmti, JNIEnv *env, jthread thread) { menter(jvmti, vm_death_lock); { if ( !vm_death_active ) { get_agent(jvmti)->thread_end(jvmti, env, thread); } } mexit(jvmti, vm_death_lock); }
static void JNICALL monitor_waited(jvmtiEnv* jvmti, JNIEnv *env, jthread thread, jobject object, jboolean timed_out) { jvmti->RawMonitorEnter(vm_death_lock); { if ( !vm_death_active ) { get_agent(jvmti)->monitor_waited(jvmti, env, thread, object, timed_out); } } jvmti->RawMonitorExit(vm_death_lock); }
static void JNICALL monitor_contended_entered(jvmtiEnv* jvmti, JNIEnv *env, jthread thread, jobject object) { jvmti->RawMonitorEnter(vm_death_lock); { if ( !vm_death_active ) { get_agent(jvmti)->monitor_contended_entered(jvmti, env, thread, object); } } jvmti->RawMonitorExit(vm_death_lock); }
static void JNICALL monitor_wait(jvmtiEnv* jvmti, JNIEnv *env, jthread thread, jobject object, jlong timeout) { menter(jvmti, vm_death_lock); { if ( !vm_death_active ) { get_agent(jvmti)->monitor_wait(jvmti, env, thread, object, timeout); } } mexit(jvmti, vm_death_lock); }
void SearchResultsMgr::display (ResultID *results) { SearchResultsAgent *sra = get_agent(); // NOTE: error checking // NOTE: save in f_active_agents sra->display (results); setStatus (eSuccess); }
JNIEXPORT void JNICALL Java_jp_marisa_AgentNative_dispose(JNIEnv *env, jobject pthis) { marisa::Agent* native_agent = get_agent(env, pthis); if (native_agent != NULL) { delete native_agent; } set_handle_value(env, pthis, "Ljp/marisa/AgentNative;", (jlong)-1); jlong handle = get_stringBufferHandle_value(env, pthis); if (handle != -1) { delete [] (char *)handle; } set_stringBufferHandle_value(env, pthis, (jlong)-1); }
static void JNICALL vm_death(jvmtiEnv *jvmti, JNIEnv *env) { Agent *agent; /* Block all callbacks */ jvmti->RawMonitorEnter(vm_death_lock); { /* Set flag for other callbacks */ vm_death_active = JNI_TRUE; /* Inform Agent instance of VM_DEATH */ agent = get_agent(jvmti); agent->vm_death(jvmti, env); /* Reclaim space of Agent */ jvmti->SetEnvironmentLocalStorage((const void*)NULL); delete agent; } jvmti->RawMonitorExit(vm_death_lock); }
JNIEXPORT jobject JNICALL Java_jp_marisa_AgentNative_query(JNIEnv *env, jobject pthis) { marisa::Agent* native_agent = get_agent(env, pthis); if (native_agent == NULL) { return NULL; } try { const marisa::Query& query = native_agent->query(); jobject obj = attach_handle(env, "Ljp/marisa/QueryNative;", (jlong)&query); return obj; } catch (const marisa::Exception& ex) { // TODO: jclass clsj = env->FindClass("Ljava/lang/UnsupportedOperationException;"); if (clsj == NULL) return NULL; env->ThrowNew(clsj, ex.error_message()); env->DeleteLocalRef(clsj); return NULL; } }
static void JNICALL vm_death(jvmtiEnv *jvmti, JNIEnv *env) { jvmtiError err; Agent *agent; /* Block all callbacks */ menter(jvmti, vm_death_lock); { /* Set flag for other callbacks */ vm_death_active = JNI_TRUE; /* Inform Agent instance of VM_DEATH */ agent = get_agent(jvmti); agent->vm_death(jvmti, env); /* Reclaim space of Agent */ err = jvmti->SetEnvironmentLocalStorage((const void*)NULL); check_jvmti_error(jvmti, err, "set env local storage"); delete agent; } mexit(jvmti, vm_death_lock); }
std::pair< Wt::WWidget*, Wt::WWidget* > generic_sys_coordinator::initialize() { std::lock_guard< std::mutex > guard(m_sys_mutex); m_widget = new sys_display_widget(m_sys_mutex); //m_widget->set_drawer(m_sys->get_drawer()); m_widget->interactive_input_sig().connect(this, &generic_sys_coordinator::on_widget_interaction); // TODO: This seems hacky, but don't want the selected series to be reset on restart, // since the system type is unchanged and therefore so are the properties auto temp_sys = m_sys_factory->create_system(); temp_sys->initialize(); for(auto const& agent : m_agents_spec.agents) { auto agent_id = temp_sys->register_agent(agent.spec);// , std::move(controller)); auto controller = std::unique_ptr< rtp::i_controller >( m_agents_spec.controller_factories[agent.controller_id]->create(&temp_sys->get_agent(agent_id)) ); temp_sys->register_agent_controller(agent_id, std::move(controller)); } Wt::WWidget* props_wt_wgt = nullptr; if(temp_sys->is_instantaneous()) { auto wgt = new properties_table_widget{}; m_props_widget = wgt; props_wt_wgt = wgt; } else { auto wgt = new properties_chart_widget{}; m_props_widget = wgt; props_wt_wgt = wgt; } m_props_widget->reset(temp_sys->get_state_properties()); return std::pair< Wt::WWidget*, Wt::WWidget* >(m_widget, props_wt_wgt); }
int main(int argc, char *argv[]) { bool source = true; struct agent_data_t data; char *password = NULL; enum action verb = ACTION_NONE; enum agent type = AGENT_DEFAULT; void (*print_env)(struct agent_data_t *data) = print_sh_env; static const struct option opts[] = { { "help", no_argument, 0, 'h' }, { "version", no_argument, 0, 'v' }, { "add", no_argument, 0, 'a' }, { "clear", no_argument, 0, 'k' }, { "kill", no_argument, 0, 'K' }, { "list", no_argument, 0, 'l' }, { "unlock", optional_argument, 0, 'u' }, { "print", no_argument, 0, 'p' }, { "sh", no_argument, 0, 's' }, { "csh", no_argument, 0, 'c' }, { "fish", no_argument, 0, 'f' }, { "agent", required_argument, 0, 't' }, { 0, 0, 0, 0 } }; while (true) { int opt = getopt_long(argc, argv, "hvakKlu::pscft:", opts, NULL); if (opt == -1) break; switch (opt) { case 'h': usage(stdout); break; case 'v': printf("%s %s\n", program_invocation_short_name, ENVOY_VERSION); return 0; case 'a': verb = ACTION_FORCE_ADD; break; case 'k': verb = ACTION_CLEAR; source = false; break; case 'K': verb = ACTION_KILL; source = false; break; case 'l': verb = ACTION_LIST; break; case 'u': verb = ACTION_UNLOCK; password = optarg; break; case 'p': verb = ACTION_PRINT; break; case 's': print_env = print_sh_env; break; case 'c': print_env = print_csh_env; break; case 'f': print_env = print_fish_env; break; case 't': type = lookup_agent(optarg); if (type < 0) errx(EXIT_FAILURE, "unknown agent: %s", optarg); break; default: usage(stderr); } } if (get_agent(&data, type, source) < 0) errx(EXIT_FAILURE, "recieved no data, did the agent fail to start?"); if (data.status == ENVOY_STOPPED) return 0; if (source) source_env(&data); switch (verb) { case ACTION_PRINT: print_env(&data); /* fall through */ case ACTION_NONE: if (data.status != ENVOY_STARTED || data.type == AGENT_GPG_AGENT) break; /* fall through */ case ACTION_FORCE_ADD: add_keys(&argv[optind], argc - optind); break; case ACTION_CLEAR: if (data.type == AGENT_GPG_AGENT) kill(data.pid, SIGHUP); else errx(EXIT_FAILURE, "only gpg-agent supports this operation"); break; case ACTION_KILL: kill(data.pid, SIGTERM); break; case ACTION_LIST: execlp("ssh-add", "ssh-add", "-l", NULL); err(EXIT_FAILURE, "failed to launch ssh-add"); case ACTION_UNLOCK: unlock(&data, password); break; default: break; } return 0; }
int main(int argc, char *argv[]) { bool source = true; bool defer = false; struct agent_data_t data; char *password = NULL; enum action verb = ACTION_NONE; enum agent type = AGENT_DEFAULT; void (*print_env)(struct agent_data_t *data) = print_sh_env; static const struct option opts[] = { { "help", no_argument, 0, 'h' }, { "version", no_argument, 0, 'v' }, { "defer", no_argument, 0, 'd' }, { "add", no_argument, 0, 'a' }, { "expunge", no_argument, 0, 'x' }, { "kill", no_argument, 0, 'k' }, { "reload", no_argument, 0, 'r' }, { "list", no_argument, 0, 'l' }, { "unlock", optional_argument, 0, 'u' }, { "print", no_argument, 0, 'p' }, { "sh", no_argument, 0, 's' }, { "csh", no_argument, 0, 'c' }, { "fish", no_argument, 0, 'f' }, { "agent", required_argument, 0, 't' }, { 0, 0, 0, 0 } }; while (true) { int opt = getopt_long(argc, argv, "hvdaxkrlu::pscft:", opts, NULL); if (opt == -1) break; switch (opt) { case 'h': usage(stdout); break; case 'v': printf("%s %s\n", program_invocation_short_name, ENVOY_VERSION); return 0; case 'd': defer = true; break; case 'a': verb = ACTION_FORCE_ADD; defer = false; break; case 'x': verb = ACTION_FORCE_EXPUNGE; defer = false; break; case 'k': verb = ACTION_KILL; source = false; break; case 'r': verb = ACTION_RELOAD; source = false; break; case 'l': verb = ACTION_LIST; break; case 'u': verb = ACTION_UNLOCK; password = optarg; break; case 'p': verb = ACTION_PRINT; break; case 's': print_env = print_sh_env; break; case 'c': print_env = print_csh_env; break; case 'f': print_env = print_fish_env; break; case 't': type = lookup_agent(optarg); if (type < 0) errx(EXIT_FAILURE, "unknown agent: %s", optarg); break; default: usage(stderr); } } if (get_agent(&data, type, source, defer) < 0) errx(EXIT_FAILURE, "recieved no data, did the agent fail to start?"); if (data.status == ENVOY_STOPPED) return 0; if (source) source_env(&data); switch (verb) { case ACTION_PRINT: print_env(&data); /* fall through */ case ACTION_NONE: if (data.type == AGENT_GPG_AGENT || !agent_started(&data)) break; if (defer) break; /* fall through */ case ACTION_FORCE_ADD: add_keys(&argv[optind], argc - optind); break; case ACTION_FORCE_EXPUNGE: expunge_keys(&argv[optind], argc - optind); break; case ACTION_KILL: if (envoy_kill_agent(type) < 0) errx(EXIT_FAILURE, "failed to kill agent"); break; case ACTION_RELOAD: reload_agent(&data); break; case ACTION_LIST: execlp("ssh-add", "ssh-add", "-l", NULL); err(EXIT_FAILURE, "failed to launch ssh-add"); case ACTION_UNLOCK: unlock(&data, password); break; default: break; } return 0; }