summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-04-18 15:11:52 +0000
committerZeev Suraski <zeev@php.net>1999-04-18 15:11:52 +0000
commit342c6e0b2328db952709dd5a35c113e2b17c1e3d (patch)
treea43236d5e2474a8f55a6e5cb9ebd262da5374770
parent2e8fb4e329bf98eb33dffad4c5fb1b49f73e7517 (diff)
downloadphp-git-342c6e0b2328db952709dd5a35c113e2b17c1e3d.tar.gz
Whatnot:
* updated alloc_persist to use critical sections * changed extension shutdown to two-phase * updated dependencies * PR support (don't remember if there was any really)
-rw-r--r--Zend/configure.in27
-rw-r--r--Zend/zend-scanner.l2
-rw-r--r--Zend/zend.c4
-rw-r--r--Zend/zend.h3
-rw-r--r--Zend/zend_API.c10
-rw-r--r--Zend/zend_API.h11
-rw-r--r--Zend/zend_alloc.c3
-rw-r--r--Zend/zend_compile.c2
-rw-r--r--Zend/zend_extensions.c17
-rw-r--r--Zend/zend_extensions.h1
-rw-r--r--Zend/zend_globals.h1
-rw-r--r--Zend/zend_llist.c16
-rw-r--r--Zend/zend_modules.h2
-rw-r--r--Zend/zend_opcode.c3
14 files changed, 59 insertions, 43 deletions
diff --git a/Zend/configure.in b/Zend/configure.in
index 201755a272..7a126467a5 100644
--- a/Zend/configure.in
+++ b/Zend/configure.in
@@ -70,20 +70,11 @@ if test -d /usr/pkg/include -a -d /usr/pkg/lib ; then
LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
fi
-AC_CHECK_LIB(nsl, gethostname, [
- LIBS="-lnsl $LIBS"
- AC_DEFINE(HAVE_LIBNSL) ], [])
-
AC_CHECK_LIB(c, socket, [:], [
AC_CHECK_LIB(socket, socket, [
LIBS="-lsocket $LIBS"
AC_DEFINE(HAVE_LIBSOCKET) ], []) ])
-AC_CHECK_LIB(c, gethostbyaddr, [:], [
- AC_CHECK_LIB(nsl, gethostbyaddr, [
- LIBS="-lnsl $LIBS"
- AC_DEFINE(HAVE_LIBNSL) ], []) ])
-
AC_CHECK_LIB(c, dlopen, [
# fake it
AC_DEFINE(HAVE_LIBDL) ], [
@@ -96,24 +87,6 @@ dnl as well as res_search resides in libsocket
AC_CHECK_LIB(c, sin, [:], [
AC_CHECK_LIB(m, sin) ])
-dnl The res_search may be in libsocket as well, and if it is
-dnl make sure to check for dn_skipname in libresolv, or if res_search
-dnl is in neither of these libs, still check for dn_skipname in libresolv
-AC_CHECK_LIB(socket, res_search, [
- AC_CHECK_LIB(resolv, dn_skipname)
- AC_CHECK_LIB(resolv, __dn_skipname)
- LIBS="$LIBS -lsocket"
- AC_DEFINE(HAVE_LIBSOCKET)
-], [
- AC_CHECK_LIB(resolv, res_search, [
- LIBS="$LIBS -lresolv"
- AC_DEFINE(HAVE_LIBRESOLV)
- ], [
- AC_CHECK_LIB(resolv, dn_skipname)
- AC_CHECK_LIB(resolv, __dn_skipname)
- ])
-])
-
dnl Checks for header files.
AC_HEADER_STDC
diff --git a/Zend/zend-scanner.l b/Zend/zend-scanner.l
index f6132dee76..279c94da42 100644
--- a/Zend/zend-scanner.l
+++ b/Zend/zend-scanner.l
@@ -243,7 +243,7 @@ zend_op_array *compile_filename(zval *filename CLS_DC)
}
file_handle.filename = filename->value.str.val;
file_handle.type = ZEND_HANDLE_FILENAME;
- retval = compile_files(0 CLS_CC, 1, &file_handle);
+ retval = zend_compile_files(0 CLS_CC, 1, &file_handle);
if (filename==&tmp) {
zval_dtor(&tmp);
}
diff --git a/Zend/zend.c b/Zend/zend.c
index 485256beae..df5f38ce2c 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -154,6 +154,8 @@ static void register_standard_class()
standard_class.handle_function_call = NULL;
standard_class.handle_property_get = NULL;
standard_class.handle_property_set = NULL;
+ standard_class.refcount = (int *) malloc(sizeof(int));
+ *standard_class.refcount = 1;
zend_hash_add(CG(class_table), "stdClass", sizeof("stdClass"), &standard_class, sizeof(zend_class_entry), NULL);
}
@@ -206,7 +208,7 @@ void zend_shutdown()
free(CG(function_table));
zend_hash_destroy(CG(class_table));
free(CG(class_table));
- zend_llist_destroy(&zend_extensions);
+ zend_shutdown_extensions();
free(zend_version_info);
zend_shutdown_constants();
}
diff --git a/Zend/zend.h b/Zend/zend.h
index 716e862299..250455af4b 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -85,7 +85,7 @@ typedef struct {
char *fname;
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
unsigned char *func_arg_types;
-} function_entry;
+} zend_function_entry;
typedef struct {
@@ -107,6 +107,7 @@ struct _zend_class_entry {
char *name;
uint name_length;
struct _zend_class_entry *parent;
+ int *refcount;
HashTable function_table;
HashTable default_properties;
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 67cfd78546..f456c8b04f 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -592,9 +592,9 @@ ZEND_API int _register_list_destructors(void (*list_destructor)(void *), void (*
/* registers all functions in *library_functions in the function hash */
-int register_functions(function_entry *functions)
+int register_functions(zend_function_entry *functions)
{
- function_entry *ptr = functions;
+ zend_function_entry *ptr = functions;
zend_internal_function internal_function;
int count=0,unload=0;
CLS_FETCH();
@@ -633,9 +633,9 @@ int register_functions(function_entry *functions)
/* count=-1 means erase all functions, otherwise,
* erase the first count functions
*/
-void unregister_functions(function_entry *functions,int count)
+void unregister_functions(zend_function_entry *functions,int count)
{
- function_entry *ptr = functions;
+ zend_function_entry *ptr = functions;
int i=0;
CLS_FETCH();
@@ -753,6 +753,8 @@ zend_class_entry *register_internal_class(zend_class_entry *class_entry)
class_entry->type = ZEND_INTERNAL_CLASS;
class_entry->parent = NULL;
+ class_entry->refcount = (int *) malloc(sizeof(int));
+ *class_entry->refcount = 1;
zend_hash_init(&class_entry->default_properties, 0, NULL, PVAL_PTR_DTOR, 1);
zend_hash_init(&class_entry->function_table, 0, NULL, (void (*)(void *)) destroy_zend_function, 1);
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 0399748cb3..100b5750ba 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -21,6 +21,13 @@
#include "zend_list.h"
+#define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
+#define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(zend_if_##name)
+
+#define ZEND_NAMED_FE(runtime_name, name, arg_types) { #runtime_name, name, arg_types },
+#define ZEND_FE(name, arg_types) ZEND_NAMED_FE(name, zend_if_##name, arg_types)
+
+
int zend_next_free_module(void);
int getParameters(int ht, int param_count,...);
@@ -32,8 +39,8 @@ int getThis(zval **this);
int ParameterPassedByReference(int ht, uint n);
-int register_functions(function_entry *functions);
-void unregister_functions(function_entry *functions, int count);
+int register_functions(zend_function_entry *functions);
+void unregister_functions(zend_function_entry *functions, int count);
int register_module(zend_module_entry *module_entry);
zend_class_entry *register_internal_class(zend_class_entry *class_entry);
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 6831ae31af..92c939cd3f 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -494,6 +494,8 @@ ZEND_API void _persist_alloc(void *ptr)
_mem_block_check(ptr, 1, filename, lineno);
#endif
+ HANDLE_BLOCK_INTERRUPTIONS();
+
/* remove the block from the non persistent list */
REMOVE_POINTER_FROM_LIST(p);
@@ -501,6 +503,7 @@ ZEND_API void _persist_alloc(void *ptr)
/* add the block to the persistent list */
ADD_POINTER_TO_LIST(p);
+ HANDLE_UNBLOCK_INTERRUPTIONS();
}
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 9ce269104f..4db89e6a3c 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1107,6 +1107,8 @@ void do_begin_class_declaration(znode *class_name, znode *parent_class_name CLS_
CG(class_entry).type = ZEND_USER_CLASS;
CG(class_entry).name = class_name->u.constant.value.str.val;
CG(class_entry).name_length = class_name->u.constant.value.str.len;
+ CG(class_entry).refcount = (int *) emalloc(sizeof(int));
+ *CG(class_entry).refcount = 1;
zend_str_tolower(CG(class_entry).name, CG(class_entry).name_length);
diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c
index fe63768dba..ce49505f12 100644
--- a/Zend/zend_extensions.c
+++ b/Zend/zend_extensions.c
@@ -100,13 +100,26 @@ int zend_load_extension(char *path)
#endif
}
-
-void zend_extension_dtor(zend_extension *extension)
+static void zend_extension_shutdown(zend_extension *extension)
{
#if ZEND_EXTENSIONS_SUPPORT
if (extension->shutdown) {
extension->shutdown(extension);
}
+#endif
+}
+
+
+void zend_shutdown_extensions()
+{
+ zend_llist_apply(&zend_extensions, (void (*)(void *)) zend_extension_shutdown);
+ zend_llist_destroy(&zend_extensions);
+}
+
+
+void zend_extension_dtor(zend_extension *extension)
+{
+#if ZEND_EXTENSIONS_SUPPORT
DL_UNLOAD(extension->handle);
#endif
}
diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h
index 97c2243e1a..502f807600 100644
--- a/Zend/zend_extensions.h
+++ b/Zend/zend_extensions.h
@@ -86,5 +86,6 @@ void zend_extension_dtor(zend_extension *extension);
int zend_load_extension(char *path);
int zend_load_extensions(char **extension_paths);
void zend_append_version_info(zend_extension *extension);
+void zend_shutdown_extensions();
#endif /* _ZEND_EXTENSIONS_H */
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h
index 9e447d7afe..727eb312a6 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -187,6 +187,7 @@ struct _zend_executor_globals {
zend_ptr_stack argument_stack;
+ void *reserved[4];
#if SUPPORT_INTERACTIVE
int interactive;
#endif
diff --git a/Zend/zend_llist.c b/Zend/zend_llist.c
index ec19038dd0..2a659cef88 100644
--- a/Zend/zend_llist.c
+++ b/Zend/zend_llist.c
@@ -72,18 +72,26 @@ ZEND_API void zend_llist_del_element(zend_llist *l, void *element)
ZEND_API void zend_llist_destroy(zend_llist *l)
{
- zend_llist_element *current=l->head, *next;
+ zend_llist_element *current, *next;
- while (current) {
- next = current->next;
- if (l->dtor) {
+ if (l->dtor) {
+ current = l->head;
+
+ while (current) {
l->dtor(current->data);
+ current = current->next;
}
+ }
+
+ current = l->head;
+ while (current) {
+ next = current->next;
pefree(current, l->persistent);
current = next;
}
}
+
ZEND_API void zend_llist_remove_tail(zend_llist *l)
{
zend_llist_element *old_tail;
diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h
index ee0b879c54..f4805f0663 100644
--- a/Zend/zend_modules.h
+++ b/Zend/zend_modules.h
@@ -28,7 +28,7 @@
typedef struct {
char *name;
- function_entry *functions;
+ zend_function_entry *functions;
int (*module_startup_func)(INIT_FUNC_ARGS);
int (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS);
int (*request_startup_func)(INIT_FUNC_ARGS);
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index a6d9e8aca0..8c53e3e807 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -111,6 +111,9 @@ ZEND_API void destroy_zend_function(zend_function *function)
ZEND_API void destroy_zend_class(zend_class_entry *ce)
{
+ if (--(*ce->refcount)>0) {
+ return;
+ }
switch (ce->type) {
case ZEND_USER_CLASS:
efree(ce->name);