diff options
author | Sascha Schumann <sas@php.net> | 2000-03-29 20:37:12 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2000-03-29 20:37:12 +0000 |
commit | af9a852bf1d12a4dfa7cd410fabf47f5edf99bce (patch) | |
tree | dd81796438b00642c74b4cfab6419f6cd898ba98 /ext/session/mod_files.c | |
parent | 88041c4fc7b0ad7c9fba04ef02f7fe7dc4b7813a (diff) | |
download | php-git-af9a852bf1d12a4dfa7cd410fabf47f5edf99bce.tar.gz |
Improved error messages
Diffstat (limited to 'ext/session/mod_files.c')
-rw-r--r-- | ext/session/mod_files.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 001984028b..64879d5969 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -145,19 +145,26 @@ static void _ps_files_open(ps_files *data, const char *key) if (data->fd != -1) flock(data->fd, LOCK_EX); #endif + + if (data->fd == -1) + php_error(E_WARNING, "open(%s, O_RDWR) failed: %m (%d)", buf, errno); } } -static void _ps_files_cleanup_dir(const char *dirname, int maxlifetime) +static int _ps_files_cleanup_dir(const char *dirname, int maxlifetime) { DIR *dir; struct dirent *entry; struct stat sbuf; char buf[MAXPATHLEN]; time_t now; + int nrdels = 0; dir = opendir(dirname); - if (!dir) return; + if (!dir) { + php_error(E_NOTICE, "_ps_files_cleanup_dir: opendir(%s) failed: %m (%d)\n", dirname, errno); + return (0); + } time(&now); @@ -172,10 +179,13 @@ static void _ps_files_cleanup_dir(const char *dirname, int maxlifetime) /* is it expired? */ (now - sbuf.st_atime) > maxlifetime) { unlink(buf); + nrdels++; } } closedir(dir); + + return (nrdels); } #define PS_FILES_DATA ps_files *data = PS_GET_MOD_DATA() @@ -277,7 +287,7 @@ PS_GC_FUNC(files) an external entity (i.e. find -ctime x | xargs rm) */ if (data->dirdepth == 0) - _ps_files_cleanup_dir(data->basedir, maxlifetime); + *nrdels = _ps_files_cleanup_dir(data->basedir, maxlifetime); return SUCCESS; } |