summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 275c9ce)
raw | patch | inline | side by side (parent: 275c9ce)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 27 Aug 2009 21:24:44 +0000 (23:24 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 27 Aug 2009 21:26:30 +0000 (23:26 +0200) |
This is an upstream patch to fix the JVM startup.
debian/changelog | patch | blob | history | |
debian/patches/00list | patch | blob | history | |
debian/patches/java-fix-jvm-start.dpatch | [new file with mode: 0755] | patch | blob |
diff --git a/debian/changelog b/debian/changelog
index c00c56eeb6c4a6e607ec0cbe365467e69ecf30d6..c7add8d0437208408a281c15b33b21a295a74c10 100644 (file)
--- a/debian/changelog
+++ b/debian/changelog
- Added plugin-fix-unregister.dpatch - upstream patch to make
'plugin_unregister_read()' functional again, thus fixing a failed
assertion in some cases.
+ - Added java-fix-jvm-start.dpatch - upstream patch to fix the JVM startup.
* debian/README.Debian:
- Removed the note about how to get collectd2html.pl working with
version 4 of collectd - the script now supports the --recursive option
- Set the 'apache' plugin's URL according to the default used by Debian's
Apache; thanks to Joey Hess for reporting this (Closes: #541888).
- -- Sebastian Harl <tokkee@debian.org> Thu, 27 Aug 2009 23:11:09 +0200
+ -- Sebastian Harl <tokkee@debian.org> Thu, 27 Aug 2009 23:23:16 +0200
collectd (4.6.3-1) unstable; urgency=low
diff --git a/debian/patches/00list b/debian/patches/00list
index 680577af72672f31d87a1d7941321ca211713c54..7297c986cedfaceb709d43dd4d12529dd9a0f2dc 100644 (file)
--- a/debian/patches/00list
+++ b/debian/patches/00list
network-fix-cacheflush.dpatch
libvirt-reconnect.dpatch
plugin-fix-unregister.dpatch
+java-fix-jvm-start.dpatch
diff --git a/debian/patches/java-fix-jvm-start.dpatch b/debian/patches/java-fix-jvm-start.dpatch
--- /dev/null
@@ -0,0 +1,127 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## java-fix-jvm-start.dpatch by Florian Forster <octo@verplant.org>
+##
+## DP: java plugin: Wait with the configuration until the daemon has forked.
+## DP
+## DP: Passing the configuration to Java-based plugins requires the JVM to be
+## DP: active and running. However, the JVM starts some threads that are lost
+## DP: when the daemon forks to the background.
+## DP:
+## DP: This patch changes the behavior of the Java plugin to copy the
+## DP: configuration blocks found to a local variable and run the configuration
+## DP: of the Java-based plugins from the `init' callback, because it is
+## DP: invoked after the daemon has forked to the background.
+
+@DPATCH@
+
+diff a/src/java.c b/src/java.c
+--- a/src/java.c
++++ b/src/java.c
+@@ -93,6 +93,8 @@ static cjni_callback_info_t *java_callbacks = NULL;
+ static size_t java_callbacks_num = 0;
+ static pthread_mutex_t java_callbacks_lock = PTHREAD_MUTEX_INITIALIZER;
+
++static oconfig_item_t *config_block = NULL;
++
+ /*
+ * Prototypes
+ *
+@@ -2304,7 +2306,7 @@ static int cjni_config_plugin_block (oconfig_item_t *ci) /* {{{ */
+ return (0);
+ } /* }}} int cjni_config_plugin_block */
+
+-static int cjni_config (oconfig_item_t *ci) /* {{{ */
++static int cjni_config_perform (oconfig_item_t *ci) /* {{{ */
+ {
+ int success;
+ int errors;
+@@ -2359,7 +2361,56 @@ static int cjni_config (oconfig_item_t *ci) /* {{{ */
+ }
+
+ return (0);
+-} /* }}} int cjni_config */
++} /* }}} int cjni_config_perform */
++
++/* Copy the children of `ci' to the global `config_block' variable. */
++static int cjni_config_callback (oconfig_item_t *ci) /* {{{ */
++{
++ oconfig_item_t *ci_copy;
++ oconfig_item_t *tmp;
++
++ assert (ci != NULL);
++ if (ci->children_num == 0)
++ return (0); /* nothing to do */
++
++ ci_copy = oconfig_clone (ci);
++ if (ci_copy == NULL)
++ {
++ ERROR ("java plugin: oconfig_clone failed.");
++ return (-1);
++ }
++
++ if (config_block == NULL)
++ {
++ config_block = ci_copy;
++ return (0);
++ }
++
++ tmp = realloc (config_block->children,
++ (config_block->children_num + ci_copy->children_num) * sizeof (*tmp));
++ if (tmp == NULL)
++ {
++ ERROR ("java plugin: realloc failed.");
++ oconfig_free (ci_copy);
++ return (-1);
++ }
++ config_block->children = tmp;
++
++ /* Copy the pointers */
++ memcpy (config_block->children + config_block->children_num,
++ ci_copy->children,
++ ci_copy->children_num * sizeof (*ci_copy->children));
++ config_block->children_num += ci_copy->children_num;
++
++ /* Delete the pointers from the copy, so `oconfig_free' can't free them. */
++ memset (ci_copy->children, 0,
++ ci_copy->children_num * sizeof (*ci_copy->children));
++ ci_copy->children_num = 0;
++
++ oconfig_free (ci_copy);
++
++ return (0);
++} /* }}} int cjni_config_callback */
+
+ /* Free the data contained in the `user_data_t' pointer passed to `cjni_read'
+ * and `cjni_write'. In particular, delete the global reference to the Java
+@@ -2995,6 +3046,22 @@ static int cjni_init (void) /* {{{ */
+ {
+ JNIEnv *jvm_env;
+
++ if ((config_block == NULL) && (jvm == NULL))
++ {
++ ERROR ("java plugin: cjni_init: No configuration block for "
++ "the java plugin was found.");
++ return (-1);
++ }
++
++ if (config_block != NULL)
++ {
++ int status;
++
++ status = cjni_config_perform (config_block);
++ oconfig_free (config_block);
++ config_block = NULL;
++ }
++
+ if (jvm == NULL)
+ {
+ ERROR ("java plugin: cjni_init: jvm == NULL");
+@@ -3013,7 +3080,7 @@ static int cjni_init (void) /* {{{ */
+
+ void module_register (void)
+ {
+- plugin_register_complex_config ("java", cjni_config);
++ plugin_register_complex_config ("java", cjni_config_callback);
+ plugin_register_init ("java", cjni_init);
+ plugin_register_shutdown ("java", cjni_shutdown);
+ } /* void module_register (void) */