lucene-pylucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r944961 - /lucene/pylucene/branches/branch_3x/jcc/jcc/sources/jcc.cpp
Date Mon, 17 May 2010 04:19:25 GMT
Author: vajda
Date: Mon May 17 04:19:25 2010
New Revision: 944961

URL: http://svn.apache.org/viewvc?rev=944961&view=rev
Log:
added call to dlopen() via initVM(export=True)

Modified:
    lucene/pylucene/branches/branch_3x/jcc/jcc/sources/jcc.cpp

Modified: lucene/pylucene/branches/branch_3x/jcc/jcc/sources/jcc.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/jcc/jcc/sources/jcc.cpp?rev=944961&r1=944960&r2=944961&view=diff
==============================================================================
--- lucene/pylucene/branches/branch_3x/jcc/jcc/sources/jcc.cpp (original)
+++ lucene/pylucene/branches/branch_3x/jcc/jcc/sources/jcc.cpp Mon May 17 04:19:25 2010
@@ -340,18 +340,51 @@ _DLL_EXPORT PyObject *initVM(PyObject *s
 {
     static char *kwnames[] = {
         "classpath", "initialheap", "maxheap", "maxstack",
-        "vmargs", NULL
+        "vmargs", "export", NULL
     };
     char *classpath = NULL;
     char *initialheap = NULL, *maxheap = NULL, *maxstack = NULL;
     char *vmargs = NULL;
+    int export_ = 0;
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzzzz", kwnames,
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzzzzi", kwnames,
                                      &classpath,
                                      &initialheap, &maxheap, &maxstack,
-                                     &vmargs))
+                                     &vmargs, &export_))
         return NULL;
 
+#ifdef linux
+    if (export_)
+    {
+        PyObject *__file__ = PyObject_GetAttrString(self, "__file__");
+
+        if (!__file__)
+            return NULL;
+
+        if (PyString_Check(__file__))
+        {
+            if (!dlopen(PyString_AS_STRING(__file__), RTLD_NOW | RTLD_GLOBAL))
+            {
+                PyErr_Format(PyExc_SystemError,
+                             "dlopen(%s, RTLD_NOW | RTLD_GLOBAL) failed",
+                             PyString_AS_STRING(__file__));
+                Py_DECREF(__file__);
+
+                return NULL;
+            }
+        }
+        else
+        {
+            PyErr_SetString(PyExc_TypeError, "__file__ is not a string");
+            Py_DECREF(__file__);
+
+            return NULL;
+        }
+         
+        Py_DECREF(__file__);
+    }
+#endif
+
     if (env->vm)
     {
         PyObject *module_cp = NULL;



Mime
View raw message