summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/session/mod_user.c24
-rw-r--r--ext/session/mod_user.h14
-rw-r--r--ext/session/php_session.h1
-rw-r--r--ext/session/session.c25
4 files changed, 34 insertions, 30 deletions
diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c
index d0bf39205e..efb52070d2 100644
--- a/ext/session/mod_user.c
+++ b/ext/session/mod_user.c
@@ -49,26 +49,18 @@ ps_module ps_mod_user = {
}
-static zval *ps_call_handler(char *name, int argc, zval **argv)
+static zval *ps_call_handler(zval *func, int argc, zval **argv)
{
int i;
zval *retval = NULL;
ELS_FETCH();
- if (name && name[0] != '\0') {
- zval *func;
-
- SESS_ZVAL_STRING(name, func);
- MAKE_STD_ZVAL(retval);
-
- if (call_user_function(EG(function_table), NULL, func, retval,
- argc, argv) == FAILURE) {
- zval_dtor(retval);
- efree(retval);
- retval = NULL;
- }
- zval_dtor(func);
- efree(func);
+ MAKE_STD_ZVAL(retval);
+ if (call_user_function(EG(function_table), NULL, func, retval,
+ argc, argv) == FAILURE) {
+ zval_dtor(retval);
+ efree(retval);
+ retval = NULL;
}
for (i = 0; i < argc; i++) {
@@ -118,7 +110,7 @@ PS_CLOSE_FUNC(user)
retval = ps_call_handler(PSF(close), 0, NULL);
for (i = 0; i < 6; i++)
- efree(mdata->names[i]);
+ zval_del_ref(&mdata->names[i]);
efree(mdata);
PS_SET_MOD_DATA(NULL);
diff --git a/ext/session/mod_user.h b/ext/session/mod_user.h
index 8d63f9a104..dbea5b9a61 100644
--- a/ext/session/mod_user.h
+++ b/ext/session/mod_user.h
@@ -20,14 +20,14 @@
#define MOD_USER_H
typedef union {
- char *names[6];
+ zval *names[6];
struct {
- char *ps_open;
- char *ps_close;
- char *ps_read;
- char *ps_write;
- char *ps_destroy;
- char *ps_gc;
+ zval *ps_open;
+ zval *ps_close;
+ zval *ps_read;
+ zval *ps_write;
+ zval *ps_destroy;
+ zval *ps_gc;
} name;
} ps_user;
diff --git a/ext/session/php_session.h b/ext/session/php_session.h
index e489be780c..5a361a32f4 100644
--- a/ext/session/php_session.h
+++ b/ext/session/php_session.h
@@ -115,6 +115,7 @@ PHP_FUNCTION(session_set_save_handler);
PHP_FUNCTION(session_cache_limiter);
PHP_FUNCTION(session_set_cookie_params);
PHP_FUNCTION(session_get_cookie_params);
+PHP_FUNCTION(session_write_close);
#ifdef ZTS
#define PSLS_D php_ps_globals *ps_globals
diff --git a/ext/session/session.c b/ext/session/session.c
index 33d36d17af..4ab1377dbb 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -65,6 +65,7 @@ function_entry session_functions[] = {
PHP_FE(session_cache_limiter, NULL)
PHP_FE(session_set_cookie_params, NULL)
PHP_FE(session_get_cookie_params, NULL)
+ PHP_FE(session_write_close, NULL)
{0}
};
@@ -1082,10 +1083,10 @@ PHP_FUNCTION(session_set_save_handler)
mdata = emalloc(sizeof(*mdata));
for (i = 0; i < 6; i++) {
- convert_to_string_ex(args[i]);
- mdata->names[i] = estrdup(Z_STRVAL_PP(args[i]));
+ ZVAL_ADDREF(*args[i]);
+ mdata->names[i] = *args[i];
}
-
+
PS(mod_data) = (void *) mdata;
RETURN_TRUE;
@@ -1390,15 +1391,25 @@ PHP_RINIT_FUNCTION(session)
return SUCCESS;
}
-
-PHP_RSHUTDOWN_FUNCTION(session)
+static void php_session_flush(PSLS_D)
{
- PSLS_FETCH();
-
if (PS(nr_open_sessions) > 0) {
php_session_save_current_state(PSLS_C);
PS(nr_open_sessions)--;
}
+}
+
+PHP_FUNCTION(session_write_close)
+{
+ PSLS_FETCH();
+ php_session_flush(PSLS_C);
+}
+
+PHP_RSHUTDOWN_FUNCTION(session)
+{
+ PSLS_FETCH();
+
+ php_session_flush(PSLS_C);
php_rshutdown_session_globals(PSLS_C);
return SUCCESS;
}