Mercurial > hg > release > icedtea-web-1.0
changeset 53:a9d3a1d07478
Fix PR552: Support for FreeBSD's pthread implementation (patch from jkim@freebsd.org)
author | Deepak Bhole <dbhole@redhat.com> |
---|---|
date | Wed, 24 Nov 2010 15:17:54 -0500 |
parents | b43d21667b5b |
children | 5267f9104d5f |
files | ChangeLog NEWS plugin/icedteanp/IcedTeaNPPlugin.cc plugin/icedteanp/IcedTeaPluginRequestProcessor.cc |
diffstat | 4 files changed, 49 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Nov 24 20:06:11 2010 +0000 +++ b/ChangeLog Wed Nov 24 15:17:54 2010 -0500 @@ -1,3 +1,16 @@ +2010-11-24 Deepak Bhole <dbhole@redhat.com> + + Fix PR552: Support for FreeBSD's pthread implementation (patch from + jkim@freebsd.org) + * plugin/icedteanp/IcedTeaNPPlugin.cc + (NP_Shutdown): Do pthread_join after cancel to avoid destroying mutexes + or condition variables in use. + * plugin/icedteanp/IcedTeaPluginRequestProcessor.cc + (PluginRequestProcessor): Initialize mutexes dynamically. + (queue_cleanup): New method. Destroy dynamically created mytexes. + (queue_processor): Initialize wait_mutex and push cleanup on exit. Clean + up after processing stops. + 2010-11-24 Andrew John Hughes <ahughes@redhat.com> * NEWS: Bring in changes from IcedTea6 1.10
--- a/NEWS Wed Nov 24 20:06:11 2010 +0000 +++ b/NEWS Wed Nov 24 15:17:54 2010 -0500 @@ -15,6 +15,7 @@ - RH645843, CVE-2010-3860: IcedTea System property information leak via public static * Plugin - PR542: Plugin fails with NPE on http://www.openprocessing.org/visuals/iframe.php?visualID=2615 + - PR552: Support for FreeBSD's pthread implementation - PR554: System.err writes content two times - PR556: Applet initialization code is prone to race conditions - PR557: Applet opens in a separate window if tab is closed when the applet loads
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc Wed Nov 24 20:06:11 2010 +0000 +++ b/plugin/icedteanp/IcedTeaNPPlugin.cc Wed Nov 24 15:17:54 2010 -0500 @@ -2372,6 +2372,10 @@ pthread_cancel(plugin_request_processor_thread2); pthread_cancel(plugin_request_processor_thread3); + pthread_join(plugin_request_processor_thread1, NULL); + pthread_join(plugin_request_processor_thread2, NULL); + pthread_join(plugin_request_processor_thread3, NULL); + java_to_plugin_bus->unSubscribe(plugin_req_proc); plugin_to_java_bus->unSubscribe(java_req_proc); //internal_bus->unSubscribe(java_req_proc);
--- a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc Wed Nov 24 20:06:11 2010 +0000 +++ b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc Wed Nov 24 15:17:54 2010 -0500 @@ -63,6 +63,12 @@ this->pendingRequests = new std::map<pthread_t, uintmax_t>(); internal_req_ref_counter = 0; + + pthread_mutex_init(&message_queue_mutex, NULL); + pthread_mutex_init(&syn_write_mutex, NULL); + pthread_mutex_init(&tc_mutex, NULL); + + pthread_cond_init(&cond_message_available, NULL); } /** @@ -77,6 +83,12 @@ if (pendingRequests) delete pendingRequests; + + pthread_mutex_destroy(&message_queue_mutex); + pthread_mutex_destroy(&syn_write_mutex); + pthread_mutex_destroy(&tc_mutex); + + pthread_cond_destroy(&cond_message_available); } /** @@ -701,6 +713,14 @@ 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 @@ PluginRequestProcessor* processor = (PluginRequestProcessor*) data; std::vector<std::string*>* message_parts = NULL; std::string command; - pthread_mutex_t wait_mutex = PTHREAD_MUTEX_INITIALIZER; // This is needed for API compat. and is unused + pthread_mutex_t wait_mutex = PTHREAD_MUTEX_INITIALIZER; PLUGIN_DEBUG("Queue processor initialized. Queue = %p\n", message_queue); + pthread_mutex_init(&wait_mutex, NULL); + + pthread_cleanup_push(queue_cleanup, (void*) &wait_mutex); + while (true) { pthread_mutex_lock(&message_queue_mutex); @@ -780,14 +804,17 @@ } else { - pthread_cond_wait(&cond_message_available, &wait_mutex); - pthread_testcancel(); + pthread_mutex_lock(&wait_mutex); + pthread_cond_wait(&cond_message_available, &wait_mutex); + pthread_mutex_unlock(&wait_mutex); } message_parts = NULL; + + pthread_testcancel(); } - PLUGIN_DEBUG("Queue processing stopped.\n"); + pthread_cleanup_pop(1); } /******************************************