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

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