cvs: /php4/ext/session mod_files.c

From: Date: Wed, 29 Mar 2000 20:37:43 +0000
Subject: cvs: /php4/ext/session mod_files.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-12830@lists.php.net to get a copy of this message
sas Wed Mar 29 12:37:43 2000 EDT Modified files: /php4/ext/session mod_files.c Log: Improved error messages Index: php4/ext/session/mod_files.c diff -u php4/ext/session/mod_files.c:1.27 php4/ext/session/mod_files.c:1.28 --- php4/ext/session/mod_files.c:1.27 Sat Feb 19 15:41:19 2000 +++ php4/ext/session/mod_files.c Wed Mar 29 12:37:12 2000 @@ -145,19 +145,26 @@ 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 @@ /* 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 @@ 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; }

« previous php.version4 (#12830) next »