diff options
author | Arpad Ray <arpad@php.net> | 2011-09-13 22:28:15 +0000 |
---|---|---|
committer | Arpad Ray <arpad@php.net> | 2011-09-13 22:28:15 +0000 |
commit | 5bc97c6cfaab487504a6330368d2c0b0eef716c0 (patch) | |
tree | 802d87d8ad2369e5e3f717128723ea040a59679e /ext/session/mod_user.c | |
parent | 449497f1628a1702f17cca963c113991097fe11c (diff) | |
download | php-git-5bc97c6cfaab487504a6330368d2c0b0eef716c0.tar.gz |
Implement object-oriented session handlers (https://wiki.php.net/rfc/session-oo)
Diffstat (limited to 'ext/session/mod_user.c')
-rw-r--r-- | ext/session/mod_user.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 61a3586bd0..f643b9eee6 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -62,15 +62,10 @@ static zval *ps_call_handler(zval *func, int argc, zval **argv TSRMLS_DC) return retval; } -#define STDVARS1 \ +#define STDVARS \ zval *retval; \ int ret = FAILURE -#define STDVARS \ - STDVARS1; \ - char *mdata = PS_GET_MOD_DATA(); \ - if (!mdata) { return FAILURE; } - #define PSF(a) PS(mod_user_names).name.ps_##a #define FINISH \ @@ -84,32 +79,28 @@ static zval *ps_call_handler(zval *func, int argc, zval **argv TSRMLS_DC) PS_OPEN_FUNC(user) { zval *args[2]; - static char dummy = 0; - STDVARS1; + STDVARS; SESS_ZVAL_STRING((char*)save_path, args[0]); SESS_ZVAL_STRING((char*)session_name, args[1]); retval = ps_call_handler(PSF(open), 2, args TSRMLS_CC); - if (retval) { - /* This is necessary to fool the session module. Yes, it's safe to - * use a static. Neither mod_user nor the session module itself will - * ever touch this pointer. It could be set to 0xDEADBEEF for all the - * difference it makes, but for the sake of paranoia it's set to some - * valid value. */ - PS_SET_MOD_DATA(&dummy); - } + PS(mod_user_implemented) = 1; FINISH; } PS_CLOSE_FUNC(user) { - STDVARS1; + STDVARS; - retval = ps_call_handler(PSF(close), 0, NULL TSRMLS_CC); + if (!PS(mod_user_implemented)) { + /* already closed */ + return SUCCESS; + } - PS_SET_MOD_DATA(NULL); + retval = ps_call_handler(PSF(close), 0, NULL TSRMLS_CC); + PS(mod_user_implemented) = 0; FINISH; } |