]> granicus.if.org Git - php/commitdiff
GC now prints out how many session objects were removed
authorSascha Schumann <sas@php.net>
Wed, 29 Mar 2000 20:37:29 +0000 (20:37 +0000)
committerSascha Schumann <sas@php.net>
Wed, 29 Mar 2000 20:37:29 +0000 (20:37 +0000)
ext/session/mod_mm.c
ext/session/php_session.h
ext/session/session.c

index 3ba73fcc3266f3c5f91c8e30bd64552aa223663e..8720bec21dced5de340d5ef4dce4982e3c61920a 100644 (file)
@@ -305,6 +305,7 @@ PS_GC_FUNC(mm)
        time_t now;
        ps_sd *sd, *next;
        
+       *nrdels = 0;
        ps_mm_debug("gc\n");
        
        mm_lock(data->mm, MM_LOCK_RW);
@@ -315,8 +316,10 @@ PS_GC_FUNC(mm)
                for (sd = data->hash[h]; sd; sd = next) {
                        next = sd->next;
                        ps_mm_debug("looking at %s\n", sd->key);
-                       if ((now - sd->ctime) > maxlifetime)
+                       if ((now - sd->ctime) > maxlifetime) {
                                ps_sd_destroy(data, sd);
+                               *nrdels++;
+                       }
                }
 
        mm_unlock(data->mm);
index ab5cb0df5ce008659107cd57e6cbd26e77648312..a017ab1e3efb6750f1f47a5a1cb8a52ac234fc41 100644 (file)
@@ -35,7 +35,7 @@
 #define PS_READ_ARGS void **mod_data, const char *key, char **val, int *vallen
 #define PS_WRITE_ARGS void **mod_data, const char *key, const char *val, const int vallen
 #define PS_DESTROY_ARGS void **mod_data, const char *key
-#define PS_GC_ARGS void **mod_data, int maxlifetime
+#define PS_GC_ARGS void **mod_data, int maxlifetime, int *nrdels
 
 typedef struct ps_module_struct {
        const char *name;
index 3a552d21e3ff86532e431661afb2c057bb3f4b2a..142570a9890ef5eccb6ebf9b5ccf761ec6cdec82 100644 (file)
@@ -813,10 +813,15 @@ static void _php_session_start(PSLS_D)
        _php_session_initialize(PSLS_C);
 
        if (PS(mod_data) && PS(gc_probability) > 0) {
+               int nrdels = -1;
+
                srand(time(NULL));
                nrand = (int) (100.0*rand()/RAND_MAX);
-               if (nrand < PS(gc_probability))
-                       PS(mod)->gc(&PS(mod_data), PS(gc_maxlifetime));
+               if (nrand < PS(gc_probability)) {
+                       PS(mod)->gc(&PS(mod_data), PS(gc_maxlifetime), &nrdels);
+                       if (nrdels != -1)
+                               php_error(E_NOTICE, "Session gc: cleared %d\n", nrdels);
+               }
        }
 }