From f88464ee6d0c65e60f8c2274fce532285d9c6588 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Sat, 19 Jun 1999 13:04:55 +0000 Subject: [PATCH] Win32/ZTS compiles again --- ext/standard/fsock.c | 26 +++++++++++--------------- main/fopen_wrappers.c | 8 +++++--- main/fopen_wrappers.h | 4 +++- main/php_globals.h | 4 ++++ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c index 1bd2c54855..0420cad037 100644 --- a/ext/standard/fsock.c +++ b/ext/standard/fsock.c @@ -87,11 +87,6 @@ extern int le_fp; #include "build-defs.h" #endif -#ifndef ZTS -static HashTable ht_keys; -static HashTable ht_socks; -#endif - static unsigned char third_and_fourth_args_force_ref[] = { 4, BYREF_NONE, BYREF_NONE, BYREF_FORCE, BYREF_FORCE }; function_entry fsock_functions[] = { @@ -130,8 +125,8 @@ php3_module_entry fsock_module_entry = { }; #ifndef ZTS -static HashTable ht_keys; -static HashTable ht_socks; +static HashTable PG(ht_fsock_keys); +static HashTable PG(ht_fsock_socks); #endif @@ -160,8 +155,9 @@ int lookup_hostname(const char *addr, struct in_addr *in) int _php3_is_persistent_sock(int sock) { char *key; + PLS_FETCH(); - if (_php3_hash_find(&ht_socks, (char *) &sock, sizeof(sock), + if (_php3_hash_find(&PG(ht_fsock_socks), (char *) &sock, sizeof(sock), (void **) &key) == SUCCESS) { return 1; } @@ -289,7 +285,7 @@ static void _php3_fsockopen(INTERNAL_FUNCTION_PARAMETERS, int persistent) { key = emalloc(args[0]->value.str.len + 10); sprintf(key, "%s:%d", args[0]->value.str.val, portno); - if (persistent && _php3_hash_find(&ht_keys, key, strlen(key) + 1, + if (persistent && _php3_hash_find(&PG(ht_fsock_keys), key, strlen(key) + 1, (void *) &sockp) == SUCCESS) { efree(key); *sock = *sockp; @@ -364,9 +360,9 @@ static void _php3_fsockopen(INTERNAL_FUNCTION_PARAMETERS, int persistent) { *sock=socketd; if (persistent) { - _php3_hash_update(&ht_keys, key, strlen(key) + 1, + _php3_hash_update(&PG(ht_fsock_keys), key, strlen(key) + 1, sock, sizeof(*sock), NULL); - _php3_hash_update(&ht_socks, (char *) sock, sizeof(*sock), + _php3_hash_update(&PG(ht_fsock_socks), (char *) sock, sizeof(*sock), key, strlen(key) + 1, NULL); } if(key) efree(key); @@ -735,8 +731,8 @@ static void _php3_msock_destroy(int *data) int php3_minit_fsock(INIT_FUNC_ARGS) { #ifndef ZTS - _php3_hash_init(&ht_keys, 0, NULL, NULL, 1); - _php3_hash_init(&ht_socks, 0, NULL, (void (*)(void *))_php3_msock_destroy, 1); + _php3_hash_init(&PG(ht_fsock_keys), 0, NULL, NULL, 1); + _php3_hash_init(&PG(ht_fsock_socks), 0, NULL, (void (*)(void *))_php3_msock_destroy, 1); #endif return SUCCESS; } @@ -746,8 +742,8 @@ int php3_minit_fsock(INIT_FUNC_ARGS) int php3_mshutdown_fsock(SHUTDOWN_FUNC_ARGS) { #ifndef ZTS - _php3_hash_destroy(&ht_socks); - _php3_hash_destroy(&ht_keys); + _php3_hash_destroy(&PG(ht_fsock_socks)); + _php3_hash_destroy(&PG(ht_fsock_keys)); #endif php_cleanup_sockbuf(1); return SUCCESS; diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index e63897cff4..8ca0076a88 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -100,13 +100,13 @@ int _php3_getftpresult(int socketd); When open_basedir is NULL, always return 0 */ -PHPAPI int _php3_check_specific_open_basedir(char *basedir, char *path) +PHPAPI int _php3_check_specific_open_basedir(char *basedir, char *path PLS_DC) { char resolved_name[MAXPATHLEN]; char resolved_basedir[MAXPATHLEN]; char local_open_basedir[MAXPATHLEN]; int local_open_basedir_pos; - PLS_FETCH(); + SLS_FETCH(); /* Special case basedir==".": Use script-directory */ if ((strcmp(PG(open_basedir), ".") == 0) && @@ -153,6 +153,8 @@ PHPAPI int _php3_check_specific_open_basedir(char *basedir, char *path) PHPAPI int _php3_check_open_basedir(char *path) { + PLS_FETCH(); + /* Only check when open_basedir is available */ if (PG(open_basedir) && *PG(open_basedir)) { char *pathbuf; @@ -174,7 +176,7 @@ PHPAPI int _php3_check_open_basedir(char *path) end++; } - if (_php3_check_specific_open_basedir(ptr, path) == 0) { + if (_php3_check_specific_open_basedir(ptr, path PLS_CC) == 0) { efree(pathbuf); return 0; } diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h index c5c69db70f..5541480dff 100644 --- a/main/fopen_wrappers.h +++ b/main/fopen_wrappers.h @@ -33,6 +33,8 @@ #ifndef _FOPEN_WRAPPERS_H #define _FOPEN_WRAPPERS_H +#include "php_globals.h" + #define IGNORE_PATH 0 #define USE_PATH 1 #define IGNORE_URL 2 @@ -84,7 +86,7 @@ extern PHPAPI FILE *php3_fopen_wrapper(char *filename, char *mode, int options, PHPAPI FILE *php3_fopen_for_parser(void); extern PHPAPI int _php3_check_open_basedir(char *path); -extern PHPAPI int _php3_check_specific_open_basedir(char *basedir, char *path); +extern PHPAPI int _php3_check_specific_open_basedir(char *basedir, char *path PLS_DC); extern PHPAPI FILE *php3_fopen_with_path(char *filename, char *mode, char *path, char **opened_path); diff --git a/main/php_globals.h b/main/php_globals.h index 0269f9ce93..55534df6a0 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -64,6 +64,10 @@ struct _php_core_globals { long y2k_compliance; unsigned char header_is_being_sent; + + /* for fsock */ + HashTable ht_fsock_keys; + HashTable ht_fsock_socks; }; -- 2.40.0