cvs: /php4/ext/standard basic_functions.c basic_functions.h pageinfo.c
| From: | Sascha Schumann | Date: | Sun, 12 Dec 1999 16:14:42 +0000 |
| Subject: | cvs: /php4/ext/standard basic_functions.c basic_functions.h pageinfo.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-7827@lists.php.net to get a copy of this message | ||
sas Sun Dec 12 11:14:42 1999 EDT
Modified files:
/php4/ext/standard basic_functions.c basic_functions.h pageinfo.c
Log:
@- Made pageinfo.c thread-safe (Sascha)
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.132 php4/ext/standard/basic_functions.c:1.133
--- php4/ext/standard/basic_functions.c:1.132 Sun Dec 5 09:16:36 1999
+++ php4/ext/standard/basic_functions.c Sun Dec 12 11:14:39 1999
@@ -400,6 +400,9 @@
BG(locale_string) = NULL;
BG(user_compare_func_name) = NULL;
BG(array_walk_func_name) = NULL;
+ BG(page_uid) = -1;
+ BG(page_inode) = -1;
+ BG(page_mtime) = -1;
#ifdef HAVE_PUTENV
if (zend_hash_init(&BG(putenv_ht), 1, NULL, (int (*)(void *)) _php3_putenv_destructor, 0) ==
FAILURE) {
return FAILURE;
Index: php4/ext/standard/basic_functions.h
diff -u php4/ext/standard/basic_functions.h:1.32 php4/ext/standard/basic_functions.h:1.33
--- php4/ext/standard/basic_functions.h:1.32 Wed Dec 1 12:21:52 1999
+++ php4/ext/standard/basic_functions.h Sun Dec 12 11:14:40 1999
@@ -29,7 +29,7 @@
*/
-/* $Id: basic_functions.h,v 1.32 1999/12/01 17:21:52 sas Exp $ */
+/* $Id: basic_functions.h,v 1.33 1999/12/12 16:14:40 sas Exp $ */
#ifndef _BASIC_FUNCTIONS_H
#define _BASIC_FUNCTIONS_H
@@ -113,6 +113,9 @@
char str_ebuf[40];
zval **array_walk_func_name;
zval **user_compare_func_name;
+ long page_uid;
+ long page_inode;
+ long page_mtime;
} php_basic_globals;
#ifdef ZTS
Index: php4/ext/standard/pageinfo.c
diff -u php4/ext/standard/pageinfo.c:1.9 php4/ext/standard/pageinfo.c:1.10
--- php4/ext/standard/pageinfo.c:1.9 Mon Aug 2 15:16:50 1999
+++ php4/ext/standard/pageinfo.c Sun Dec 12 11:14:40 1999
@@ -15,7 +15,7 @@
| Authors: Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: pageinfo.c,v 1.9 1999/08/02 19:16:50 zeev Exp $ */
+/* $Id: pageinfo.c,v 1.10 1999/12/12 16:14:40 sas Exp $ */
#include "php.h"
#include "pageinfo.h"
@@ -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 @@
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 @@
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 @@
long _php3_getuid(void)
{
+ BLS_FETCH();
+
_php3_statpage();
- return (page_uid);
+ return (BG(page_uid));
}
/* {{{ proto int getmyuid(void)
@@ -123,11 +123,13 @@
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 @@
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));
}
}
/* }}} */