From 304b4adbb916ee07db6b3ee3bf9a3de815269a96 Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Mon, 10 Feb 2014 15:33:13 +0100
Subject: [PATCH 41/43] Make sure that agent_onload and agent_onunload are
processed only once
Related to rhbz#1063322
---
src/abrt-checker.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/abrt-checker.c b/src/abrt-checker.c
index 713053c..e9caada 100644
--- a/src/abrt-checker.c
+++ b/src/abrt-checker.c
@@ -2923,10 +2923,17 @@ JNIEXPORT jint JNICALL Agent_OnLoad(
char *options,
void *reserved __UNUSED_VAR)
{
+ static int already_called = 0;
jvmtiEnv *jvmti_env = NULL;
jvmtiError error_code = JVMTI_ERROR_NONE;
jint result;
+ /* we need to make sure the agent is initialized once */
+ if (already_called) {
+ return JNI_OK;
+ }
+
+ already_called = 1;
pthread_mutex_init(&abrt_print_mutex, /*attr*/NULL);
INFO_PRINT("Agent_OnLoad\n");
@@ -3001,6 +3008,15 @@ JNIEXPORT jint JNICALL Agent_OnLoad(
*/
JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm __UNUSED_VAR)
{
+ static int already_called = 0;
+
+ /* we need to make sure the agent is initialized once */
+ if (already_called) {
+ return;
+ }
+
+ already_called = 1;
+
pthread_mutex_destroy(&abrt_print_mutex);
INFO_PRINT("Agent_OnUnLoad\n");
--
1.8.3.1