summaryrefslogtreecommitdiff
path: root/ext/standard/pageinfo.c
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>1999-12-12 16:14:40 +0000
committerSascha Schumann <sas@php.net>1999-12-12 16:14:40 +0000
commitd9258da42e7e05163798c71ed8c98b5caab52718 (patch)
tree1a6123b95b4c44d3da5c974b39bec1c700ab413c /ext/standard/pageinfo.c
parentf30278b96b25c630ec89ba8cc0bec259eb5b9ed8 (diff)
downloadphp-git-d9258da42e7e05163798c71ed8c98b5caab52718.tar.gz
@- Made pageinfo.c thread-safe (Sascha)
Diffstat (limited to 'ext/standard/pageinfo.c')
-rw-r--r--ext/standard/pageinfo.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/ext/standard/pageinfo.c b/ext/standard/pageinfo.c
index 464d2a0bed..188b5bad4e 100644
--- a/ext/standard/pageinfo.c
+++ b/ext/standard/pageinfo.c
@@ -38,19 +38,17 @@
#include <process.h>
#endif
-#ifndef THREAD_SAFE
-static long page_uid = -1;
-static long page_inode = -1;
-static long page_mtime = -1;
-#endif
+#include "ext/standard/basic_functions.h"
static void _php3_statpage(void)
{
#if !APACHE
char *path;
struct stat sb;
+ BLS_FETCH();
#else
request_rec *r;
+ BLS_FETCH();
SLS_FETCH();
r = ((request_rec *) SG(server_context));
@@ -62,11 +60,11 @@ static void _php3_statpage(void)
values. We can afford it, and it means we don't have to
worry about resetting the static variables after every
hit. */
- page_uid = r ->finfo.st_uid;
- page_inode = r->finfo.st_ino;
- page_mtime = r->finfo.st_mtime;
+ BG(page_uid) = r ->finfo.st_uid;
+ BG(page_inode) = r->finfo.st_ino;
+ BG(page_mtime) = r->finfo.st_mtime;
#else
- if (page_uid == -1) {
+ if (BG(page_uid) == -1) {
SLS_FETCH();
path = SG(request_info).path_translated;
@@ -75,9 +73,9 @@ static void _php3_statpage(void)
php_error(E_WARNING, "Unable to find file: '%s'", path);
return;
}
- page_uid = sb.st_uid;
- page_inode = sb.st_ino;
- page_mtime = sb.st_mtime;
+ BG(page_uid) = sb.st_uid;
+ BG(page_inode) = sb.st_ino;
+ BG(page_mtime) = sb.st_mtime;
}
}
#endif
@@ -85,8 +83,10 @@ static void _php3_statpage(void)
long _php3_getuid(void)
{
+ BLS_FETCH();
+
_php3_statpage();
- return (page_uid);
+ return (BG(page_uid));
}
/* {{{ proto int getmyuid(void)
@@ -123,11 +123,13 @@ PHP_FUNCTION(getmypid)
Get the inode of the current script being parsed */
PHP_FUNCTION(getmyinode)
{
+ BLS_FETCH();
+
_php3_statpage();
- if (page_inode < 0) {
+ if (BG(page_inode) < 0) {
RETURN_FALSE;
} else {
- RETURN_LONG(page_inode);
+ RETURN_LONG(BG(page_inode));
}
}
/* }}} */
@@ -136,11 +138,13 @@ PHP_FUNCTION(getmyinode)
Get time of last page modification */
PHP_FUNCTION(getlastmod)
{
+ BLS_FETCH();
+
_php3_statpage();
- if (page_mtime < 0) {
+ if (BG(page_mtime) < 0) {
RETURN_FALSE;
} else {
- RETURN_LONG(page_mtime);
+ RETURN_LONG(BG(page_mtime));
}
}
/* }}} */