Blame SOURCES/0041-Make-sure-that-agent_onload-and-agent_onunload-are-p.patch

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