summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2010-09-24 03:54:19 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2010-09-24 03:54:19 +0000
commit773071c6f04136ea0f33fe94db5e488297ba2d13 (patch)
tree98837a63c1d6d8efa4fd3887b38b3d2f8ed8c262 /java
parentPurge automake15 from existence. Only a few more to go now. (diff)
Improve pthread cancellation and update comments.
Notes
Notes: svn path=/head/; revision=261751
Diffstat (limited to 'java')
-rw-r--r--java/openjdk6/files/icedtea.patch48
1 files changed, 34 insertions, 14 deletions
diff --git a/java/openjdk6/files/icedtea.patch b/java/openjdk6/files/icedtea.patch
index e16d7ef75892..2e8bad1691a0 100644
--- a/java/openjdk6/files/icedtea.patch
+++ b/java/openjdk6/files/icedtea.patch
@@ -4,21 +4,23 @@ This patch works around POSIX thread implementation differences between
FreeBSD's libthr and Linux's NPTL:
- We do not support static allocations of mutex and condition variable.
-Thus, we must initialize them explicitly with pthread_mutex_init(3) and
-pthread_cond_init(3), respectively.
+Instead, they are allocated dynamically when they are used for the first
+time if they are properly initialized with PTHREAD_MUTEX_INITIALIZER and
+PTHREAD_COND_INITIALIZER. Thus, we explicitly initialize and destroy
+them to be safer.
- We must initialize mutex before calling pthread_cond_wait(3). Otherwise,
it fails with EINVAL.
- We must lock mutex before calling pthread_cond_wait(3). Otherwise, it
-fails with EPERM.
+fails with EPERM. This is a POSIX requirement.
- We must join threads via pthread_join(3) after calling pthread_cancel(3).
Otherwise, we may destroy mutex or condition variable in use.
---- icedtea6-1.9/plugin/icedteanp/IcedTeaNPPlugin.cc.orig 2010-09-23 09:40:49.000000000 -0400
-+++ icedtea6-1.9/plugin/icedteanp/IcedTeaNPPlugin.cc 2010-09-23 15:31:27.000000000 -0400
-@@ -2369,6 +2369,10 @@ NP_Shutdown (void)
+--- icedtea6-1.9/plugin/icedteanp/IcedTeaNPPlugin.cc.orig 2010-08-06 07:05:21.916103000 -0400
++++ icedtea6-1.9/plugin/icedteanp/IcedTeaNPPlugin.cc 2010-09-23 21:52:17.000000000 -0400
+@@ -2355,6 +2355,10 @@ NP_Shutdown (void)
pthread_cancel(plugin_request_processor_thread2);
pthread_cancel(plugin_request_processor_thread3);
@@ -29,8 +31,8 @@ Otherwise, we may destroy mutex or condition variable in use.
java_to_plugin_bus->unSubscribe(plugin_req_proc);
plugin_to_java_bus->unSubscribe(java_req_proc);
//internal_bus->unSubscribe(java_req_proc);
---- icedtea6-1.9/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc.orig 2010-09-23 09:40:49.000000000 -0400
-+++ icedtea6-1.9/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc 2010-09-23 15:36:38.000000000 -0400
+--- icedtea6-1.9/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc.orig 2010-08-06 07:05:21.996828000 -0400
++++ icedtea6-1.9/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc 2010-09-23 22:01:37.000000000 -0400
@@ -63,6 +63,12 @@ PluginRequestProcessor::PluginRequestPro
this->pendingRequests = new std::map<pthread_t, uintmax_t>();
@@ -57,7 +59,22 @@ Otherwise, we may destroy mutex or condition variable in use.
}
/**
-@@ -709,10 +721,12 @@ queue_processor(void* data)
+@@ -701,6 +713,14 @@ PluginRequestProcessor::finalize(std::ve
+ plugin_to_java_bus->post(response.c_str());
+ }
+
++static void
++queue_cleanup(void* data)
++{
++
++ pthread_mutex_destroy((pthread_mutex_t*) data);
++
++ PLUGIN_DEBUG("Queue processing stopped.\n");
++}
+
+ void*
+ queue_processor(void* data)
+@@ -709,10 +729,14 @@ queue_processor(void* data)
PluginRequestProcessor* processor = (PluginRequestProcessor*) data;
std::vector<std::string*>* message_parts = NULL;
std::string command;
@@ -68,10 +85,12 @@ Otherwise, we may destroy mutex or condition variable in use.
+ pthread_mutex_init(&wait_mutex, NULL);
+
++ pthread_cleanup_push(queue_cleanup, (void*) &wait_mutex);
++
while (true)
{
pthread_mutex_lock(&message_queue_mutex);
-@@ -780,13 +794,17 @@ queue_processor(void* data)
+@@ -780,14 +804,17 @@ queue_processor(void* data)
} else
{
@@ -80,14 +99,15 @@ Otherwise, we may destroy mutex or condition variable in use.
+ pthread_mutex_lock(&wait_mutex);
+ pthread_cond_wait(&cond_message_available, &wait_mutex);
+ pthread_mutex_unlock(&wait_mutex);
-+ pthread_testcancel();
}
message_parts = NULL;
++
++ pthread_testcancel();
}
-+ pthread_mutex_destroy(&wait_mutex);
-+
- PLUGIN_DEBUG("Queue processing stopped.\n");
+- PLUGIN_DEBUG("Queue processing stopped.\n");
++ pthread_cleanup_pop(1);
}
+ /******************************************