[nspluginwrapper] Restart workaround for Adobe Reader plugin (rhbz#645599)

Martin Stransky stransky at fedoraproject.org
Wed Jul 18 14:17:44 UTC 2012


commit 6b24415a77a7a8b01a9717e731a944c3ce271670
Author: Martin Stransky <stransky at anakreon.cz>
Date:   Wed Jul 18 16:17:38 2012 +0200

    Restart workaround for Adobe Reader plugin (rhbz#645599)

 nspluginwrapper-1.4.4-restart.patch |   77 +++++++++++++++++++++++++++++++++++
 nspluginwrapper.spec                |    5 ++
 2 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/nspluginwrapper-1.4.4-restart.patch b/nspluginwrapper-1.4.4-restart.patch
new file mode 100644
index 0000000..e8fba47
--- /dev/null
+++ b/nspluginwrapper-1.4.4-restart.patch
@@ -0,0 +1,77 @@
+diff -up nspluginwrapper-1.4.4/src/npw-wrapper.c.restart nspluginwrapper-1.4.4/src/npw-wrapper.c
+--- nspluginwrapper-1.4.4/src/npw-wrapper.c.restart	2011-07-01 05:18:57.000000000 +0200
++++ nspluginwrapper-1.4.4/src/npw-wrapper.c	2012-07-18 15:49:11.329877655 +0200
+@@ -115,6 +115,7 @@ static void plugin_exit(void);
+ static void plugin_kill_cb(rpc_connection_t *connection, void *user_data);
+ static NPError plugin_start(void);
+ static NPError plugin_start_if_needed(void);
++static void plugin_kill(void);
+ static int plugin_killed = 0;
+ 
+ /*
+@@ -2104,31 +2105,44 @@ g_NPP_New(NPMIMEType mime_type, NPP inst
+ 		  uint16_t mode, int16_t argc, char *argn[], char *argv[],
+ 		  NPSavedData *saved)
+ {
++  NPError ret;
++  int attempt = 1;
++
+   if (instance == NULL)
+ 	return NPERR_INVALID_INSTANCE_ERROR;
+-	
+-  // Check if we need to restart the plug-in
+-  NPError ret = plugin_start_if_needed();
+-  if (ret != NPERR_NO_ERROR)
+-  	return ret;
+ 
+-  PluginInstance *plugin = npw_plugin_instance_new(&PluginInstanceClass);
+-  if (plugin == NULL)
+-	return NPERR_OUT_OF_MEMORY_ERROR;
+-  plugin->instance = instance;
+-  plugin->instance_id = id_create(plugin);
+-  plugin->connection = rpc_connection_ref(g_rpc_connection);
+-  instance->pdata = plugin;
++  do {
++    // Check if we need to restart the plug-in
++    NPError ret = plugin_start_if_needed();
++    if (ret != NPERR_NO_ERROR)
++      return ret;
++
++    PluginInstance *plugin = npw_plugin_instance_new(&PluginInstanceClass);
++    if (plugin == NULL)
++      return NPERR_OUT_OF_MEMORY_ERROR;
++    plugin->instance = instance;
++    plugin->instance_id = id_create(plugin);
++    plugin->connection = rpc_connection_ref(g_rpc_connection);
++    instance->pdata = plugin;
++
++    if (PLUGIN_DIRECT_EXEC) {
++      if ((plugin->native_instance = NPW_MemNew0(NPP_t, 1)) == NULL)
++        return NPERR_OUT_OF_MEMORY_ERROR;
++      plugin->native_instance->ndata = instance->ndata;
++    }
++
++    D(bugiI("NPP_New instance=%p\n", instance));
++    ret = invoke_NPP_New(plugin, mime_type, mode, argc, argn, argv, saved);
++    D(bugiD("NPP_New return: %d [%s]\n", ret, string_of_NPError(ret)));
++
++    // NPP_New was succesfull or we exhausted all our restart attempts
++    if(!ret || attempt == 0)
++      break;
+ 
+-  if (PLUGIN_DIRECT_EXEC) {
+-	if ((plugin->native_instance = NPW_MemNew0(NPP_t, 1)) == NULL)
+-	  return NPERR_OUT_OF_MEMORY_ERROR;
+-	plugin->native_instance->ndata = instance->ndata;
+-  }
+-
+-  D(bugiI("NPP_New instance=%p\n", instance));
+-  ret = invoke_NPP_New(plugin, mime_type, mode, argc, argn, argv, saved);
+-  D(bugiD("NPP_New return: %d [%s]\n", ret, string_of_NPError(ret)));
++    // kill the plugin
++    plugin_kill();
++    attempt--;
++  } while(1);
+ 
+   if (saved) {
+ 	if (saved->buf)
diff --git a/nspluginwrapper.spec b/nspluginwrapper.spec
index f5b9ab2..c058110 100644
--- a/nspluginwrapper.spec
+++ b/nspluginwrapper.spec
@@ -100,6 +100,7 @@ Patch7:		nspluginwrapper-1.3.0-comp.patch
 Patch9:		nspluginwrapper-1.3.0-timeout.patch
 Patch10:	nspluginwrapper-pthread.patch
 Patch11:	nspluginwrapper-arm.patch
+Patch12:	nspluginwrapper-1.4.4-restart.patch
 Patch100:	plugin-config-setuid.patch
 Patch101:	plugin-config-umask.patch
 Patch102:	plugin-config-print.patch
@@ -136,6 +137,7 @@ THREAD_LIBS=`pkg-config --libs gthread-2.0`
 sed -e "s/__PTHREAD_LIBS__/$THREAD_LIBS/" %{P:%%PATCH10} > pthread.patch
 %{__patch} -p1 -b --suffix .version --fuzz=0 < pthread.patch
 %patch11 -p1 -b .arm
+%patch12 -p1 -b .restart
 
 # Plugin-config patches
 pushd %plugin_config_name
@@ -261,6 +263,9 @@ fi;
 
 
 %changelog
+* Wed Jul 18 2012 Martin Stransky <stransky at redhat.com> 1.4.4-10
+- Restart workaround for Adobe Reader plugin (rhbz#645599)
+
 * Tue May 15 2012 Peter Robinson <pbrobinson at fedoraproject.org> 1.4.4-9
 - Enable building on ARM, add patch to detect CPU
 


More information about the scm-commits mailing list