Add session_write_close(). This is primarily intended to enable

script writers to release the lock associated with the session lock
before the request finishes.

You can pass arrays now to session_set_save_handler(), so that the handlers
can be located in an object for better abstraction.
This commit is contained in:
Sascha Schumann 2000-10-11 19:47:15 +00:00
parent 0fd6a7ed18
commit d2d5320ee8
4 changed files with 34 additions and 30 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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

View file

@ -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,8 +1083,8 @@ 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;
@ -1390,15 +1391,25 @@ PHP_RINIT_FUNCTION(session)
return SUCCESS;
}
static void php_session_flush(PSLS_D)
{
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();
if (PS(nr_open_sessions) > 0) {
php_session_save_current_state(PSLS_C);
PS(nr_open_sessions)--;
}
php_session_flush(PSLS_C);
php_rshutdown_session_globals(PSLS_C);
return SUCCESS;
}