From 71ac5da86488ace3ebb3f3fa4adc747a511634e2 Mon Sep 17 00:00:00 2001
From: Pavel Tisnovsky <ptisnovs@dhcp-lab-190.englab.brq.redhat.com>
Date: Mon, 3 Feb 2014 18:00:35 +0100
Subject: [PATCH 2/2] Make sure that agent_onload and agent_onunload are
processed only once.
---
src/abrt-checker.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/abrt-checker.c b/src/abrt-checker.c
index 713053c..f142d7e 100644
--- a/src/abrt-checker.c
+++ b/src/abrt-checker.c
@@ -2923,10 +2923,17 @@ JNIEXPORT jint JNICALL Agent_OnLoad(
char *options,
void *reserved __UNUSED_VAR)
{
+ static int already_called = 0;
jvmtiEnv *jvmti_env = NULL;
jvmtiError error_code = JVMTI_ERROR_NONE;
jint result;
+ /* we need to make sure the agent is initialized once */
+ if (already_called) {
+ return;
+ }
+
+ already_called = 1;
pthread_mutex_init(&abrt_print_mutex, /*attr*/NULL);
INFO_PRINT("Agent_OnLoad\n");
@@ -3001,6 +3008,15 @@ JNIEXPORT jint JNICALL Agent_OnLoad(
*/
JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm __UNUSED_VAR)
{
+ static int already_called = 0;
+
+ /* we need to make sure the agent is initialized once */
+ if (already_called) {
+ return;
+ }
+
+ already_called = 1;
+
pthread_mutex_destroy(&abrt_print_mutex);
INFO_PRINT("Agent_OnUnLoad\n");
--
1.8.3.1