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

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