]> granicus.if.org Git - php/commitdiff
(PHP session_destroy) return the error condition from storage handler's
authorSascha Schumann <sas@php.net>
Wed, 5 Jul 2000 01:26:22 +0000 (01:26 +0000)
committerSascha Schumann <sas@php.net>
Wed, 5 Jul 2000 01:26:22 +0000 (01:26 +0000)
session_destroy method.

Submitted by: juhl@eisenstein.dk

ext/session/mod_files.c
ext/session/session.c

index a4b7ed0a4d34f38be2e0213d26adfc1e7be0d81a..c1f7ecc9bad5f4a1dc2f2eba837e9dc6948e94da 100644 (file)
@@ -275,7 +275,9 @@ PS_DESTROY_FUNC(files)
        if (!_ps_files_path_create(buf, sizeof(buf), data, key))
                return FAILURE;
        
-       V_UNLINK(buf);
+       if (V_UNLINK(buf) == -1) {
+               return FAILURE;
+       }
 
        return SUCCESS;
 }
index 0d634f240e1d2f10631b34518dd784cf95c014a8..5b685eadb0ddef2dca5fb6996b9b6777aa97402d 100644 (file)
@@ -138,7 +138,7 @@ PHP_MINFO_FUNCTION(session);
 
 static void php_rinit_session_globals(PSLS_D);
 static void php_rshutdown_session_globals(PSLS_D);
-static void _php_session_destroy(PSLS_D);
+static zend_bool _php_session_destroy(PSLS_D);
 
 zend_module_entry session_module_entry = {
        "session",
@@ -874,18 +874,24 @@ static void _php_session_start(PSLS_D)
        }
 }
 
-static void _php_session_destroy(PSLS_D)
+static zend_bool _php_session_destroy(PSLS_D)
 {
+       zend_bool retval = SUCCESS;
+
        if (PS(nr_open_sessions) == 0) {
                php_error(E_WARNING, "Trying to destroy uninitialized session");
-               return;
+               return FAILURE;
        }
 
        if (PS(mod)->destroy(&PS(mod_data), PS(id)) == FAILURE) {
+               retval = FAILURE;
                php_error(E_WARNING, "Destroying the session object failed");
        }
+       
        php_rshutdown_session_globals(PSLS_C);
        php_rinit_session_globals(PSLS_C);
+
+       return retval;
 }
 
 
@@ -1224,13 +1230,17 @@ PHP_FUNCTION(session_start)
 }
 /* }}} */
 
-/* {{{ proto void session_destroy(void)
+/* {{{ proto bool session_destroy(void)
    Destroy the current session and all data associated with it */
 PHP_FUNCTION(session_destroy)
 {
        PSLS_FETCH();
-               
-       _php_session_destroy(PSLS_C);
+
+       if (_php_session_destroy(PSLS_C) == SUCCESS) {
+               RETURN_TRUE;
+       } else {
+               RETURN_FALSE;
+       }
 }
 /* }}} */