time_t now;
ps_sd *sd, *next;
+ *nrdels = 0;
ps_mm_debug("gc\n");
mm_lock(data->mm, MM_LOCK_RW);
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);
#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;
_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);
+ }
}
}