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

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