[sascha@schumann.cx: [PHP-CVS] cvs: php4 /ext/session mod_user.c mod_user.h php_session.h session.c]

Chuck Hagenbuch chuck@horde.org
Wed, 11 Oct 2000 15:50:30 -0400


do we want to modify the code we provide in lib/Session/pgsql.php to take
advantage of this?

----- Forwarded message from Sascha Schumann <sascha@schumann.cx> -----

From: "Sascha Schumann" <sascha@schumann.cx>
To: php-cvs@lists.php.net
Date: Wed, 11 Oct 2000 19:47:15 -0000
Subject: [PHP-CVS] cvs: php4 /ext/session mod_user.c mod_user.h php_session.h session.c  

sas		Wed Oct 11 12:47:15 2000 EDT

  Modified files:
    /php4/ext/session	mod_user.c mod_user.h php_session.h session.c 
  Log:
  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.
  
  
Index: php4/ext/session/mod_user.c
diff -u php4/ext/session/mod_user.c:1.8 php4/ext/session/mod_user.c:1.9
--- php4/ext/session/mod_user.c:1.8	Mon Jul 10 03:09:14 2000
+++ php4/ext/session/mod_user.c	Wed Oct 11 12:47:15 2000
@@ -49,26 +49,18 @@
 }
 
 
-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 @@
 	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);
Index: php4/ext/session/mod_user.h
diff -u php4/ext/session/mod_user.h:1.5 php4/ext/session/mod_user.h:1.6
--- php4/ext/session/mod_user.h:1.5	Mon Jul 10 03:09:14 2000
+++ php4/ext/session/mod_user.h	Wed Oct 11 12:47:15 2000
@@ -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;
 
Index: php4/ext/session/php_session.h
diff -u php4/ext/session/php_session.h:1.35 php4/ext/session/php_session.h:1.36
--- php4/ext/session/php_session.h:1.35	Wed Sep  6 07:16:12 2000
+++ php4/ext/session/php_session.h	Wed Oct 11 12:47:15 2000
@@ -115,6 +115,7 @@
 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
Index: php4/ext/session/session.c
diff -u php4/ext/session/session.c:1.176 php4/ext/session/session.c:1.177
--- php4/ext/session/session.c:1.176	Wed Sep 27 08:24:09 2000
+++ php4/ext/session/session.c	Wed Oct 11 12:47:15 2000
@@ -65,6 +65,7 @@
 	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 @@
 	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 @@
 	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;
 }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net
For additional commands, e-mail: php-cvs-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net


----- End forwarded message -----
-chuck

--
Charles Hagenbuch, <chuck@horde.org>
--
...and remember: elmo is _not_ an insertion toy.