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

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