changeset in /hg/icedtea6: - Replace TCP/IP model with fifo pipes
Deepak Bhole
dbhole at redhat.com
Fri Oct 17 01:03:10 PDT 2008
changeset 2262032cc2ae in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=2262032cc2ae
description:
- Replace TCP/IP model with fifo pipes
- Improved performance
- Centralize debugging, subject to environment variable ICEDTEAPLUGIN_DEBUG
- Improved security by using per context privileges, rather than consulting
security manager.
- Add code for better panel resizing.
- Reverted icedtea-webstart.patch -- the new version of the patch made it in by mistake
diffstat:
21 files changed, 1347 insertions(+), 1062 deletions(-)
ChangeLog | 33
IcedTeaPlugin.cc | 1505 ++++++-----
Makefile.am | 32
configure.ac | 14
patches/icedtea-webstart.patch | 257 -
plugin/icedtea/netscape/javascript/JSObject.java | 39
plugin/icedtea/netscape/javascript/JSRunnable.java | 4
plugin/icedtea/sun/applet/AppletSecurityContextManager.java | 2
plugin/icedtea/sun/applet/GetMemberPluginCallRequest.java | 4
plugin/icedtea/sun/applet/GetWindowPluginCallRequest.java | 2
plugin/icedtea/sun/applet/PluginAppletSecurityContext.java | 39
plugin/icedtea/sun/applet/PluginAppletViewer.java | 220 +
plugin/icedtea/sun/applet/PluginDebug.java | 2
plugin/icedtea/sun/applet/PluginMain.java | 49
plugin/icedtea/sun/applet/PluginMessageConsumer.java | 2
plugin/icedtea/sun/applet/PluginMessageHandlerWorker.java | 4
plugin/icedtea/sun/applet/PluginObjectStore.java | 26
plugin/icedtea/sun/applet/PluginStreamHandler.java | 134
plugin/icedtea/sun/applet/RequestQueue.java | 2
plugin/icedtea/sun/applet/TestEnv.java | 36
plugin/icedtea/sun/applet/VoidPluginCallRequest.java | 3
diffs (truncated from 4626 to 500 lines):
diff -r 2a478f4ccb83 -r 2262032cc2ae ChangeLog
--- a/ChangeLog Thu Oct 16 11:37:44 2008 -0400
+++ b/ChangeLog Thu Oct 16 23:37:17 2008 -0400
@@ -1,3 +1,36 @@ 2008-10-16 Lillian Angel <langel at redha
+2008-10-16 Deepak Bhole <dbhole at redhat.com>
+
+ * IcedTeaPlugin.cc: Use fifo pipes instead of tcp/ip, make debug output
+ optional, update how security is handled.
+ * Makefile.am: Make liveconnect the default plugin
+ * configure.ac: Same.
+ * icedtea-webstart.patch: Revert to old revision. The new revision was
+ never meant to go in.
+ * plugin/icedtea/netscape/javascript/JSObject.java: Change println's to
+ debug().
+ * plugin/icedtea/netscape/javascript/JSRunnable.java: Same.
+ * plugin/icedtea/sun/applet/AppletSecurityContextManager.java: Same.
+ * plugin/icedtea/sun/applet/GetMemberPluginCallRequest.java: Same.
+ * plugin/icedtea/sun/applet/GetWindowPluginCallRequest.java: Same.
+ * plugin/icedtea/sun/applet/PluginAppletSecurityContext.java: Same, and
+ add some time calculation output to guage performance.
+ * plugin/icedtea/sun/applet/PluginAppletViewer.java: Update panel resizing
+ code, centralize debug output calls.
+ * plugin/icedtea/sun/applet/PluginDebug.java: Make debug output based on
+ environment variable "ICEDTEAPLUGIN_DEBUG".
+ * plugin/icedtea/sun/applet/PluginMain.java: Update to make use of fifo. Make
+ stream redirectionoptional, depending on the environment variable
+ "ICEDTEAPLUGIN_DEBUG".
+ * plugin/icedtea/sun/applet/PluginMessageConsumer.java: Centralize debug
+ output calls.
+ * plugin/icedtea/sun/applet/PluginMessageHandlerWorker.java: Same.
+ * plugin/icedtea/sun/applet/PluginObjectStore.java: Same.
+ * plugin/icedtea/sun/applet/PluginStreamHandler.java: Add some time
+ calculation code, update to use new transfer model over fifo.
+ * plugin/icedtea/sun/applet/RequestQueue.java: Centralize debug output calls.
+ * plugin/icedtea/sun/applet/TestEnv.java: Same.
+ * plugin/icedtea/sun/applet/VoidPluginCallRequest.java: Same.
+
2008-10-16 Lillian Angel <langel at redhat.com>
* configure.ac: Updated version from 1.3 to 1.3.1.
diff -r 2a478f4ccb83 -r 2262032cc2ae IcedTeaPlugin.cc
--- a/IcedTeaPlugin.cc Thu Oct 16 11:37:44 2008 -0400
+++ b/IcedTeaPlugin.cc Thu Oct 16 23:37:17 2008 -0400
@@ -59,6 +59,10 @@ PRThread* current_thread ();
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
+
+// GLib includes.
+#include <glib.h>
+#include <glib/gstdio.h>
// GTK includes.
#include <gtk/gtk.h>
@@ -86,6 +90,46 @@ PRThread* current_thread ();
#define ID(object) \
(object == NULL ? (PRUint32) 0 : reinterpret_cast<JNIReference*> (object)->identifier)
+#if 1
+// Debugging macros.
+
+#define PLUGIN_DEBUG_0ARG(str) \
+ if (getenv ("ICEDTEAPLUGIN_DEBUG")) \
+ { \
+ printf (str); \
+ }
+
+#define PLUGIN_DEBUG_1ARG(str, arg1) \
+ if (getenv ("ICEDTEAPLUGIN_DEBUG")) \
+ { \
+ printf (str, arg1); \
+ }
+
+#define PLUGIN_DEBUG_2ARG(str, arg1, arg2) \
+ if (getenv ("ICEDTEAPLUGIN_DEBUG")) \
+ { \
+ printf (str, arg1, arg2); \
+ }
+
+#define PLUGIN_DEBUG_3ARG(str, arg1, arg2, arg3) \
+ if (getenv ("ICEDTEAPLUGIN_DEBUG")) \
+ { \
+ printf (str, arg1, arg2, arg3); \
+ }
+
+#define PLUGIN_DEBUG_4ARG(str, arg1, arg2, arg3, arg4) \
+ if (getenv ("ICEDTEAPLUGIN_DEBUG")) \
+ { \
+ printf (str, arg1, arg2, arg3, arg4); \
+ }
+
+#define PLUGIN_DEBUG(message) \
+ PLUGIN_DEBUG_1ARG ("ICEDTEA PLUGIN: %s\n", message)
+
+#define PLUGIN_DEBUG_TWO(first, second) \
+ PLUGIN_DEBUG_2ARG ("ICEDTEA PLUGIN: %s %s\n", \
+ first, second)
+
// Tracing.
class Trace
{
@@ -94,28 +138,19 @@ public:
{
Trace::name = name;
Trace::function = function;
- printf ("ICEDTEA PLUGIN: %s%s\n",
+ PLUGIN_DEBUG_2ARG ("ICEDTEA PLUGIN: %s%s\n",
name, function);
}
~Trace ()
{
- printf ("ICEDTEA PLUGIN: %s%s %s\n",
+ PLUGIN_DEBUG_3ARG ("ICEDTEA PLUGIN: %s%s %s\n",
name, function, "return");
}
private:
char const* name;
char const* function;
};
-
-#if 1
-// Debugging macros.
-#define PLUGIN_DEBUG(message) \
- printf ("ICEDTEA PLUGIN: %s\n", message)
-
-#define PLUGIN_DEBUG_TWO(first, second) \
- printf ("ICEDTEA PLUGIN: %s %s\n", \
- first, second)
// Testing macro.
#define PLUGIN_TEST(expression, message) \
@@ -127,6 +162,18 @@ private:
} \
while (0);
+#include <sys/time.h>
+#include <unistd.h>
+
+inline suseconds_t get_time_in_ms()
+{
+ struct timeval tv;
+ struct timezone tz;
+ gettimeofday(&tv, &tz);
+
+ return tv.tv_usec;
+}
+
// __func__ is a variable, not a string literal, so it cannot be
// concatenated by the preprocessor.
#define PLUGIN_TRACE_JNIENV() Trace _trace ("JNIEnv::", __func__)
@@ -152,7 +199,9 @@ private:
#define PLUGIN_CHECK_RETURN(message, result) \
if (NS_SUCCEEDED (result)) \
+ { \
PLUGIN_DEBUG (message); \
+ } \
else \
{ \
PLUGIN_ERROR (message); \
@@ -161,9 +210,12 @@ private:
#define PLUGIN_CHECK(message, result) \
if (NS_SUCCEEDED (result)) \
+ { \
PLUGIN_DEBUG (message); \
- else \
- PLUGIN_ERROR (message);
+ } else \
+ { \
+ PLUGIN_ERROR (message); \
+ }
#else
@@ -241,6 +293,7 @@ private:
// and set to NULL after each use.
static GError* channel_error = NULL;
// Fully-qualified appletviewer executable.
+gchar* data_directory = NULL;
static char* appletviewer_executable = NULL;
static char* libjvm_so = NULL;
@@ -248,6 +301,23 @@ class IcedTeaPluginFactory;
static PRBool factory_created = PR_FALSE;
static IcedTeaPluginFactory* factory = NULL;
+
+// Applet viewer input channel (needs to be static because it is used in plugin_in_pipe_callback)
+GIOChannel* in_from_appletviewer = NULL;
+
+// Callback used to monitor input pipe status.
+static gboolean plugin_in_pipe_callback (GIOChannel* source,
+ GIOCondition condition,
+ gpointer plugin_data);
+
+#include <prmon.h>
+#include <queue>
+#include <nsCOMPtr.h>
+#include <nsIThread.h>
+
+PRMonitor *jvmMsgQueuePRMonitor;
+std::queue<nsCString> jvmMsgQueue;
+nsCOMPtr<nsIThread> processThread;
#include <nspr.h>
@@ -267,12 +337,12 @@ JNIReference::JNIReference (PRUint32 ide
: identifier (identifier),
count (0)
{
- printf ("JNIReference CONSTRUCT: %d %p\n", identifier, this);
+ PLUGIN_DEBUG_2ARG ("JNIReference CONSTRUCT: %d %p\n", identifier, this);
}
JNIReference::~JNIReference ()
{
- printf ("JNIReference DECONSTRUCT: %d %p\n", identifier, this);
+ PLUGIN_DEBUG_2ARG ("JNIReference DECONSTRUCT: %d %p\n", identifier, this);
}
class JNIID : public JNIReference
@@ -287,12 +357,12 @@ JNIID::JNIID (PRUint32 identifier, char
: JNIReference (identifier),
signature (strdup (signature))
{
- printf ("JNIID CONSTRUCT: %d %p\n", identifier, this);
+ PLUGIN_DEBUG_2ARG ("JNIID CONSTRUCT: %d %p\n", identifier, this);
}
JNIID::~JNIID ()
{
- printf ("JNIID DECONSTRUCT: %d %p\n", identifier, this);
+ PLUGIN_DEBUG_2ARG ("JNIID DECONSTRUCT: %d %p\n", identifier, this);
}
char const* TYPES[10] = { "Object",
@@ -306,7 +376,6 @@ char const* TYPES[10] = { "Object",
"double",
"void" };
-#include <nsIThread.h>
// FIXME: create index from security context.
#define MESSAGE_CREATE() \
@@ -316,20 +385,28 @@ char const* TYPES[10] = { "Object",
#define MESSAGE_ADD_STACK_REFERENCE(reference) \
message += " reference "; \
message.AppendInt (reference); \
- if (factory->result_map[reference] == NULL) { \
- factory->result_map[reference] = new ResultContainer(); \
- printf("ResultMap created -- %p %d\n", factory->result_map[reference], factory->result_map[reference]->returnIdentifier); \
+ if (!factory->result_map.Get(reference, NULL)) { \
+ ResultContainer *resultC = new ResultContainer(); \
+ factory->result_map.Put(reference, resultC); \
+ PLUGIN_DEBUG_3ARG ("ResultMap %p created for reference %d found = %d\n", resultC, reference, factory->result_map.Get(reference, NULL)); \
+ ResultContainer *searched; \
+ factory->result_map.Get(reference, &searched); \
+ PLUGIN_DEBUG_1ARG ("Searched returned %d\n", searched->returnIdentifier); \
} \
else \
- factory->result_map[reference]->Clear();
+ { \
+ ResultContainer *resultC; \
+ factory->result_map.Get(reference, &resultC); \
+ resultC->Clear(); \
+ }
#define MESSAGE_ADD_SRC(src) \
message += " src "; \
message += src;
-#define MESSAGE_ADD_PRIVILEGES() \
+#define MESSAGE_ADD_PRIVILEGES(ctx) \
nsCString privileges(""); \
- GetEnabledPrivileges(&privileges); \
+ GetEnabledPrivileges(&privileges, ctx); \
if (privileges.Length() > 0) \
{ \
message += " privileges "; \
@@ -401,11 +478,13 @@ char const* TYPES[10] = { "Object",
// shutdown (so that the permanent loop does not block
// proper exit). We need better error handling
-#define PROCESS_PENDING_EVENTS_REF(reference) \
+#define PROCESS_PENDING_EVENTS_REF2(reference) \
+ ResultContainer *resultC; \
+ factory->result_map.Get(reference, &resultC); \
if (factory->shutting_down == PR_TRUE && \
- factory->result_map[reference]->errorOccurred == PR_TRUE) \
+ resultC->errorOccurred == PR_TRUE) \
{ \
- printf("Error occured. Exiting function\n"); \
+ PLUGIN_DEBUG_0ARG("Error occured. Exiting function\n"); \
return NS_ERROR_FAILURE; \
} \
PRBool hasPending; \
@@ -413,8 +492,16 @@ char const* TYPES[10] = { "Object",
if (hasPending == PR_TRUE) { \
PRBool processed = PR_FALSE; \
factory->current->ProcessNextEvent(PR_TRUE, &processed); \
+ } else if (g_main_context_pending (NULL)) { \
+ g_main_context_iteration(NULL, false); \
} else { \
PR_Sleep(PR_INTERVAL_NO_WAIT); \
+ }
+
+
+#define PROCESS_PENDING_EVENTS_REF(reference) \
+ if (g_main_context_pending (NULL)) { \
+ g_main_context_iteration(NULL, false); \
}
#define PROCESS_PENDING_EVENTS \
@@ -429,57 +516,63 @@ char const* TYPES[10] = { "Object",
#define MESSAGE_RECEIVE_REFERENCE(reference, cast, name) \
nsresult res = NS_OK; \
- printf ("RECEIVE 1\n"); \
- while (factory->result_map[reference]->returnIdentifier == -1 &&\
- factory->result_map[reference]->errorOccurred == PR_FALSE) \
+ PLUGIN_DEBUG_0ARG ("RECEIVE 1\n"); \
+ ResultContainer *resultC; \
+ factory->result_map.Get(reference, &resultC); \
+ while (resultC->returnIdentifier == -1 &&\
+ resultC->errorOccurred == PR_FALSE) \
{ \
PROCESS_PENDING_EVENTS_REF (reference); \
} \
- printf ("RECEIVE 3\n"); \
- if (factory->result_map[reference]->returnIdentifier == 0 || \
- factory->result_map[reference]->errorOccurred == PR_TRUE) \
+ PLUGIN_DEBUG_0ARG ("RECEIVE 3\n"); \
+ if (resultC->returnIdentifier == 0 || \
+ resultC->errorOccurred == PR_TRUE) \
{ \
*name = NULL; \
} else { \
*name = \
reinterpret_cast<cast> \
- (factory->references.ReferenceObject (factory->result_map[reference]->returnIdentifier)); \
+ (factory->references.ReferenceObject (resultC->returnIdentifier)); \
} \
- printf ("RECEIVE_REFERENCE: %s result: %x = %d\n", \
- __func__, *name, factory->result_map[reference]->returnIdentifier);
+ PLUGIN_DEBUG_3ARG ("RECEIVE_REFERENCE: %s result: %x = %d\n", \
+ __func__, *name, resultC->returnIdentifier);
// FIXME: track and free JNIIDs.
#define MESSAGE_RECEIVE_ID(reference, cast, id, signature) \
PRBool processed = PR_FALSE; \
nsresult res = NS_OK; \
- printf("RECEIVE ID 1\n"); \
- while (factory->result_map[reference]->returnIdentifier == -1 &&\
- factory->result_map[reference]->errorOccurred == PR_FALSE) \
+ PLUGIN_DEBUG_0ARG ("RECEIVE ID 1\n"); \
+ ResultContainer *resultC; \
+ factory->result_map.Get(reference, &resultC); \
+ while (resultC->returnIdentifier == -1 &&\
+ resultC->errorOccurred == PR_FALSE) \
{ \
PROCESS_PENDING_EVENTS_REF (reference); \
} \
\
- if (factory->result_map[reference]->errorOccurred == PR_TRUE) \
+ if (resultC->errorOccurred == PR_TRUE) \
{ \
*id = NULL; \
} else \
{ \
*id = reinterpret_cast<cast> \
- (new JNIID (factory->result_map[reference]->returnIdentifier, signature)); \
- printf ("RECEIVE_ID: %s result: %x = %d, %s\n", \
- __func__, *id, factory->result_map[reference]->returnIdentifier, \
+ (new JNIID (resultC->returnIdentifier, signature)); \
+ PLUGIN_DEBUG_4ARG ("RECEIVE_ID: %s result: %x = %d, %s\n", \
+ __func__, *id, resultC->returnIdentifier, \
signature); \
}
#define MESSAGE_RECEIVE_VALUE(reference, ctype, result) \
nsresult res = NS_OK; \
- printf("RECEIVE VALUE 1\n"); \
- while (factory->result_map[reference]->returnValue == "" && \
- factory->result_map[reference]->errorOccurred == PR_FALSE) \
+ PLUGIN_DEBUG_0ARG ("RECEIVE VALUE 1\n"); \
+ ResultContainer *resultC; \
+ factory->result_map.Get(reference, &resultC); \
+ while (resultC->returnValue == "" && \
+ resultC->errorOccurred == PR_FALSE) \
{ \
PROCESS_PENDING_EVENTS_REF (reference); \
} \
- *result = ParseValue (type, factory->result_map[reference]->returnValue);
+ *result = ParseValue (type, resultC->returnValue);
// \
// char* valueString = ValueString (type, *result); \
// printf ("RECEIVE_VALUE: %s result: %x = %s\n", \
@@ -490,18 +583,20 @@ char const* TYPES[10] = { "Object",
#define MESSAGE_RECEIVE_SIZE(reference, result) \
PRBool processed = PR_FALSE; \
nsresult res = NS_OK; \
- printf("RECEIVE SIZE 1\n"); \
- while (factory->result_map[reference]->returnValue == "" && \
- factory->result_map[reference]->errorOccurred == PR_FALSE) \
+ PLUGIN_DEBUG_0ARG("RECEIVE SIZE 1\n"); \
+ ResultContainer *resultC; \
+ factory->result_map.Get(reference, &resultC); \
+ while (resultC->returnValue == "" && \
+ resultC->errorOccurred == PR_FALSE) \
{ \
PROCESS_PENDING_EVENTS_REF (reference); \
} \
nsresult conversionResult; \
- if (factory->result_map[reference]->errorOccurred == PR_TRUE) \
+ if (resultC->errorOccurred == PR_TRUE) \
*result = NULL; \
else \
{ \
- *result = factory->result_map[reference]->returnValue.ToInteger (&conversionResult); \
+ *result = resultC->returnValue.ToInteger (&conversionResult); \
PLUGIN_CHECK ("parse integer", conversionResult); \
}
// \
@@ -512,19 +607,21 @@ char const* TYPES[10] = { "Object",
#define MESSAGE_RECEIVE_STRING(reference, char_type, result) \
PRBool processed = PR_FALSE; \
nsresult res = NS_OK; \
- printf("RECEIVE STRING 1\n"); \
- while (factory->result_map[reference]->returnValue == "" && \
- factory->result_map[reference]->errorOccurred == PR_FALSE) \
+ PLUGIN_DEBUG_0ARG("RECEIVE STRING 1\n"); \
+ ResultContainer *resultC; \
+ factory->result_map.Get(reference, &resultC); \
+ while (resultC->returnValue == "" && \
+ resultC->errorOccurred == PR_FALSE) \
{ \
PROCESS_PENDING_EVENTS_REF (reference); \
} \
- if (factory->result_map[reference]->errorOccurred == PR_TRUE) \
+ if (resultC->errorOccurred == PR_TRUE) \
*result = NULL; \
else \
{\
- printf("Setting result to: %s\n", strdup (factory->result_map[reference]->returnValue.get ())); \
+ PLUGIN_DEBUG_1ARG("Setting result to: %s\n", strdup (resultC->returnValue.get ())); \
*result = reinterpret_cast<char_type const*> \
- (strdup (factory->result_map[reference]->returnValue.get ()));\
+ (strdup (resultC->returnValue.get ()));\
}
// \
// printf ("RECEIVE_STRING: %s result: %x = %s\n", \
@@ -534,21 +631,22 @@ char const* TYPES[10] = { "Object",
#define MESSAGE_RECEIVE_STRING_UCS(reference, result) \
PRBool processed = PR_FALSE; \
nsresult res = NS_OK; \
- printf("RECEIVE STRING UCS 1\n"); \
- while (factory->result_map[reference]->returnValueUCS.IsEmpty() && \
- factory->result_map[reference]->errorOccurred == PR_FALSE) \
+ PLUGIN_DEBUG_0ARG("RECEIVE STRING UCS 1\n"); \
+ ResultContainer *resultC; \
+ factory->result_map.Get(reference, &resultC); \
+ while (resultC->returnValueUCS.IsEmpty() && \
+ resultC->errorOccurred == PR_FALSE) \
{ \
PROCESS_PENDING_EVENTS_REF (reference); \
} \
- if (factory->result_map[reference]->errorOccurred == PR_TRUE) \
+ if (resultC->errorOccurred == PR_TRUE) \
*result = NULL; \
else \
{ \
- int length = factory->result_map[reference]->returnValueUCS.Length (); \
+ int length = resultC->returnValueUCS.Length (); \
jchar* newstring = static_cast<jchar*> (PR_Malloc (length)); \
memset (newstring, 0, length); \
- memcpy (newstring, factory->result_map[reference]->returnValueUCS.get (), length); \
- std::cout << "Setting result to: " << factory->result_map[reference]->returnValueUCS.get() << std::endl; \
+ memcpy (newstring, resultC->returnValueUCS.get (), length); \
*result = static_cast<jchar const*> (newstring); \
}
@@ -559,16 +657,18 @@ char const* TYPES[10] = { "Object",
#define MESSAGE_RECEIVE_BOOLEAN(reference, result) \
PRBool processed = PR_FALSE; \
nsresult res = NS_OK; \
- printf("RECEIVE BOOLEAN 1\n"); \
- while (factory->result_map[reference]->returnIdentifier == -1 && \
- factory->result_map[reference]->errorOccurred == PR_FALSE) \
+ PLUGIN_DEBUG_0ARG("RECEIVE BOOLEAN 1\n"); \
+ ResultContainer *resultC; \
+ factory->result_map.Get(reference, &resultC); \
+ while (resultC->returnIdentifier == -1 && \
+ resultC->errorOccurred == PR_FALSE) \
{ \
PROCESS_PENDING_EVENTS_REF (reference); \
} \
- if (factory->result_map[reference]->errorOccurred == PR_TRUE) \
+ if (resultC->errorOccurred == PR_TRUE) \
More information about the distro-pkg-dev
mailing list