Re: [PHP-DEV] persistent java virtual machine under PHP

2002-12-05 Thread Maróy Ákos
Tony J. White wrote:

Actually, the JVM is unloaded by php.  In the latest CVS the code from
destroy_jvm() has been removed that tried to dlclose() the JVM.  This was
done because it is impossible to dlclose() a JVM because DestroyJavaVM()
is broken in all JNI implementations.


I see. But if you dlclose()-it, what happens to open resources, like 
open file descriptors, network sockets, etc? It seems to be a crude way 
of unloading the JVM...


Akos



--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Re: persistent java virtual machine under PHP

2002-12-05 Thread Maróy Ákos
Ivan Ristic wrote:

  There is a servlet which accepts requests and uses native
  code from libphp4.so to execute them. At the same time,
  the Java extension is used to provide access to Java
  objects from PHP itself.


but the ext/java as it is would not be suitable, as it would spawn new 
JVMs every once in a while (thus it would use a different JVM then the 
one that called the PHP page). the solution would be to pass the JVM 
somehow to the PHP page (maybe as a global variable?), and then make it 
use that JVM when executing JNI calls.

So a solution would be then:

- from java, use JNI to call function in libphp4.so
- libphp4.so, properly called, would execute a PHP script
- this PHP script could call java functions through JNI, using a JVM 
passed to it somehow

Where can I find documentation for calling libphp4.so? How do I execute 
a PHP script by calling some functions in libphp4.so?


Akos


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: persistent java virtual machine under PHP

2002-12-05 Thread Maróy Ákos
Derick Rethans wrote:

Have a look at www.vl-srm.net, and more even the article about it @ 
http://www.vl-srm.net/doc/articles/php-almanac-2002.php (the part about 
Bananas might be th emost relevant thing).

Thanks for the info. Though I could implement a similar deamon in java, 
and call it through XML PRC or other similar way via a network socket. 
(As my original intention was to fire up a JVM and call java functions 
from there.) But using network sockets is far mor expensive than calling 
through JNI. In my case, it seems that such a solution would not worth it.


Akos


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Re: persistent java virtual machine under PHP

2002-12-05 Thread Maróy Ákos
Ivan Ristic wrote:

  Right, but you can still use shared memory, or, you can store
  persistent objects onto the filesystem. We've done the later
  with satisfactory results.


Point taken. But this only allows to share resources that can be copied 
into and from IPC shared memory. Some resources (like open database 
connections, or a JVM) are not like that, even though they are expensive 
to create.

  Apache 2 resolves this problem. You can configure it to
  run multithreaded. Still, the issue of having a stable PHP remains.


Interesting. Does PHP run with apache 2?


Akos



--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: persistent java virtual machine under PHP

2002-12-05 Thread Maróy Ákos
Ivan Ristic wrote:

  From the web serving point of view it isn't. Since Apache usually
  interfaces to all kinds of modules and programs, the fact that
  processes die naturally from time to time helps remove cumulative
  errors.


IMHO this is a last-resort safeguard to prevent a system from falling 
due to badly written applications. But this can not be a reason for 
deciding on the architecture.

  From the PHP point of view, you can get problems with persistent
  database connections on a very high load site, that's true. But
  that's about the only problem. Sure, you can't build a persistent
  storage of information in the server but that's a minor issue.


It's not a minor issue. Using persistent objects that are expensive to 
aquire is a common pattern, which can improve performance significantly. 
The above scenario prevents exactly that.

I guess this is more of an apache issue then a PHP issue. I'd have to 
look more closely at the apache sources to investigate further.

  correctly and handle multithreading - is simply not worth it.


By my measurements, it is worth it.


  (BTW, isn't nsapi the API for the Netscape web server?)


Yes, it is.


Akos



--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: persistent java virtual machine under PHP

2002-12-04 Thread Maróy Ákos
Brad LaFountain wrote:

Are you sure its getting unloaded or is it starting up in another httpd?


I'm not sure which. The only thing I see is that global static variables 
in the shared object have their values re-initialized.


Akos



--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] persistent java virtual machine under PHP

2002-12-04 Thread Maróy Ákos
Hi,

I'm trying to use the PHP / Java integration (the module in ext/java). 
My problem is that the Java Virtual Machine is thrown out regularly by 
the PHP engine.

What happens is that the function jvm_create() gets called regularly 
when requesting new pages using the Java extension, from the function 
java_call_function_handler():

  if (!JG(jenv)) jvm_create(TSRMLS_C);

It seems that JG(jenv) gets to be 0 every once in a while. One problem 
is that on none such occasion is jvm_destroy() called, which could lead 
to resource leaks.

What I'm looking for is that the JVM would not be discarded on a regular 
basis, but it would remain persistent. Unfortunately I can't find the 
mechanism that removes it (so as to disable it).

I was looking at the documentation for extending PHP, especially at 
http://www.php.net/manual/en/phpdevel.php#phpdevel-addfunc-reslist
Maybe this is the way to go? If so, can someone elaborate on the use of 
this functionality? I can't really grasp how to use this based on the 
description there (i.e. what does 'type of resource' mean, etc.)


Akos


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php