Re: Re: restore user opcode handler in PHP
| From: | yoram bar haim | Date: | Mon, 13 Feb 2012 09:38:00 +0000 |
| Subject: | Re: Re: restore user opcode handler in PHP | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-57823@lists.php.net to get a copy of this message | ||
Here is a simple test program that reproduce the issue on mac:
lib.h:
#include "lib.h"
void set_index(int index, int value);
int get_index(int index);
lib.c:
#include "lib.h"
static int glob_var[] = {0,0,0,0};
void set_index(int index, int value) {
glob_var[index] = value;
}
int get_index(int index) {
return glob_var[index];
}
main.c:
#include <stdio.h>
#include <dlfcn.h>
#include "lib.h"
int main() {
void *handle = dlopen ("lib.so",0);
set_index(0,1);
dlclose(handle);
handle = dlopen ("lib.so",0);
printf("%d\n",get_index(0));
return 0;
}
shell> gcc -o lib.so -shared lib.c
shell> gcc -o main main.c lib.so
shell> ./main
On Monday, February 13, 2012 11:16:41 AM Stas Malyshev wrote:
> Hi!
>
> > I'm not familiar with Mac, but I saw such behavior on Linux very long
> > time ago, when on PHP restart static variables were still keep values
> > from old process.
>
> That might happen if the shared library was not unloaded (dlopen will
> not re-load library that is already loaded) however I don't understand
> how it can happen on Apache - it's supposed to dlclose all modules. Is
> it reproducible on any Apache version on Linux or Mac?