Author: mladen.turk(a)jboss.com
Date: 2007-10-04 01:43:07 -0400 (Thu, 04 Oct 2007)
New Revision: 1083
Modified:
trunk/sight/java/org/jboss/sight/Library.java
trunk/sight/native/share/library.c
Log:
Make clear and terminate methods synchronized
Modified: trunk/sight/java/org/jboss/sight/Library.java
===================================================================
--- trunk/sight/java/org/jboss/sight/Library.java 2007-10-03 16:58:16 UTC (rev 1082)
+++ trunk/sight/java/org/jboss/sight/Library.java 2007-10-04 05:43:07 UTC (rev 1083)
@@ -76,7 +76,7 @@
/* create global SIGHT APR pool
* This has to be the first call to SIGHT library.
*/
- private static native boolean initialize();
+ private static native boolean initialize0();
/* destroy global SIGHT APR pool
* This has to be the last call to SIGHT library.
@@ -134,7 +134,7 @@
throw new UnsatisfiedLinkError("Unsupported APR Version (" +
getAprVersionString() + ")");
}
- if (initialize()) {
+ if (initialize0()) {
/* Initialize Runtime objects */
File.initializeStdFiles();
@@ -155,7 +155,9 @@
{
try {
if (_instance != null) {
- terminate0();
+ synchronized(_instance) {
+ terminate0();
+ }
}
else {
throw new UnsatisfiedLinkError("Library was not initialized");
@@ -186,9 +188,11 @@
throws Exception
{
if (_instance != null) {
- clear0();
- /* Reinitialize Runtime objects */
- File.initializeStdFiles();
+ synchronized(_instance) {
+ clear0();
+ /* Reinitialize Runtime objects */
+ File.initializeStdFiles();
+ }
}
else {
throw new UnsatisfiedLinkError("Library was not initialized");
Modified: trunk/sight/native/share/library.c
===================================================================
--- trunk/sight/native/share/library.c 2007-10-03 16:58:16 UTC (rev 1082)
+++ trunk/sight/native/share/library.c 2007-10-04 05:43:07 UTC (rev 1083)
@@ -153,7 +153,7 @@
}
}
-SIGHT_EXPORT_DECLARE(jboolean, Library, initialize)(SIGHT_STDARGS)
+SIGHT_EXPORT_DECLARE(jboolean, Library, initialize0)(SIGHT_STDARGS)
{
UNREFERENCED_STDARGS;
@@ -235,7 +235,7 @@
{
UNREFERENCED_STDARGS;
- /* TODO Add reference count */
+
if (sight_global_pool) {
#if SIGHT_APR_REFCOUNT
apr_uint32_t ioc = 0;
@@ -246,6 +246,8 @@
fprintf(stderr, "Global Atomic counter : %d\n", sight_global_a);
#endif
#if SIGHT_APR_REFCOUNT
+ /* Wait until all JNI calls are done
+ */
while (in_object_count) {
apr_thread_yield();
in_object_count = apr_atomic_read32(sight_global_atomic);
@@ -366,9 +368,9 @@
throwAprException(_E, APR_TIMEUP);
return;
}
-
+
#endif
-
+
apr_pool_clear(sight_global_pool);
apr_atomic_set32(sight_global_atomic, 1);
}
Show replies by date