diff options
author | Deepak Bhole <dbhole@redhat.com> | 2011-06-08 14:38:52 -0400 |
---|---|---|
committer | Deepak Bhole <dbhole@redhat.com> | 2011-06-08 14:38:52 -0400 |
commit | 57a1d6169ce4b03610a1ba56567821f16cf661ce (patch) | |
tree | 6e850d89a19999b19a67009bacb472a8db72a7f4 /plugin/icedteanp/IcedTeaJavaRequestProcessor.cc | |
parent | bb07f5268340fcb25ccc80130d2be0e0b9820760 (diff) |
Fix PR721: IcedTeaPlugin.so cannot run g_main_context_iteration on a different thread unless a different GMainContext *context is used
Diffstat (limited to 'plugin/icedteanp/IcedTeaJavaRequestProcessor.cc')
-rw-r--r-- | plugin/icedteanp/IcedTeaJavaRequestProcessor.cc | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc index 8b5b8a3..5520206 100644 --- a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc +++ b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc @@ -247,22 +247,43 @@ JavaRequestProcessor::postAndWaitForResponse(std::string message) plugin_to_java_bus->post(message.c_str()); // Wait for result to be filled in. - struct timespec curr_t; + struct timespec curr_t; + + bool isPluginThread = false; + + if (pthread_self() == itnp_plugin_thread_id) + { + isPluginThread = true; + PLUGIN_DEBUG("JRP is in plug-in thread...\n"); + } do { - clock_gettime(CLOCK_REALTIME, &curr_t); + clock_gettime(CLOCK_REALTIME, &curr_t); - if (!result_ready && (curr_t.tv_sec < t.tv_sec)) - { - if (g_main_context_pending(NULL)) - g_main_context_iteration(NULL, false); - else - usleep(200); - } - else - break; + if (!result_ready && (curr_t.tv_sec < t.tv_sec)) + { + if (isPluginThread) + { + processAsyncCallQueue(NULL); + // Let the browser run its pending events too + if (g_main_context_pending(NULL)) + { + g_main_context_iteration(NULL, false); + } else + { + usleep(1000); // 1ms + } + } else + { + usleep(1000); // 1ms + } + } + else + { + break; + } } while (1); if (curr_t.tv_sec >= t.tv_sec) |