Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions ext/openssl/xp_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#endif

#include "php.h"
#include "ext/standard/file.h"
#include "ext/uri/php_uri.h"
#include "streams/php_streams_int.h"
#include "zend_smart_str.h"
Expand Down Expand Up @@ -3680,9 +3679,9 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val
if (value == -1) {
if (sslsock->s.timeout.tv_sec == -1) {
#ifdef _WIN32
tv.tv_sec = (long)FG(default_socket_timeout);
tv.tv_sec = (long)PG(default_socket_timeout);
#else
tv.tv_sec = (time_t)FG(default_socket_timeout);
tv.tv_sec = (time_t)PG(default_socket_timeout);
#endif
tv.tv_usec = 0;
} else {
Expand Down Expand Up @@ -4053,9 +4052,9 @@ php_stream *php_openssl_ssl_socket_factory(const char *proto, size_t protolen,
sslsock->s.is_blocked = true;
/* this timeout is used by standard stream funcs, therefore it should use the default value */
#ifdef _WIN32
sslsock->s.timeout.tv_sec = (long)FG(default_socket_timeout);
sslsock->s.timeout.tv_sec = (long)PG(default_socket_timeout);
#else
sslsock->s.timeout.tv_sec = (time_t)FG(default_socket_timeout);
sslsock->s.timeout.tv_sec = (time_t)PG(default_socket_timeout);
#endif
sslsock->s.timeout.tv_usec = 0;

Expand Down
4 changes: 1 addition & 3 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
#include "php.h"

#include "php_network.h"
#include "ext/standard/file.h"
#include "ext/standard/info.h"
#include "php_ini.h"
#ifdef PHP_WIN32
# include "windows_common.h"
# include <windows.h>
Expand Down Expand Up @@ -2789,7 +2787,7 @@ PHP_FUNCTION(socket_export_stream)
stream_data = (php_netstream_data_t *) stream->abstract;
stream_data->socket = socket->bsd_socket;
stream_data->is_blocked = socket->blocking;
stream_data->timeout.tv_sec = FG(default_socket_timeout);
stream_data->timeout.tv_sec = PG(default_socket_timeout);
stream_data->timeout.tv_usec = 0;

php_stream_to_zval(stream, &socket->zstream);
Expand Down
10 changes: 0 additions & 10 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,6 @@ PHP_RINIT_FUNCTION(basic) /* {{{ */

/* Setup default context */
FG(default_context) = NULL;

/* Default to global wrappers only */
FG(stream_wrappers) = NULL;

/* Default to global filters only */
FG(stream_filters) = NULL;

return SUCCESS;
}
/* }}} */
Expand Down Expand Up @@ -457,9 +450,6 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */
}
}

/* FG(stream_wrappers) and FG(stream_filters) are destroyed
* during php_request_shutdown() */

PHP_RSHUTDOWN(filestat)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
#ifdef HAVE_SYSLOG_H
BASIC_RSHUTDOWN_SUBMODULE(syslog);
Expand Down
10 changes: 0 additions & 10 deletions ext/standard/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,9 @@ static void file_globals_dtor(php_file_globals *file_globals_p)
#endif
}

static PHP_INI_MH(OnUpdateAutoDetectLineEndings)
{
if (zend_ini_parse_bool(new_value)) {
zend_error(E_DEPRECATED, "auto_detect_line_endings is deprecated");
}
return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
}

PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("user_agent", NULL, PHP_INI_ALL, OnUpdateStr, user_agent, php_file_globals, file_globals)
STD_PHP_INI_ENTRY("from", NULL, PHP_INI_ALL, OnUpdateStr, from_address, php_file_globals, file_globals)
STD_PHP_INI_ENTRY("default_socket_timeout", "60", PHP_INI_ALL, OnUpdateLong, default_socket_timeout, php_file_globals, file_globals)
STD_PHP_INI_BOOLEAN("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateAutoDetectLineEndings, auto_detect_line_endings, php_file_globals, file_globals)
PHP_INI_END()

PHP_MINIT_FUNCTION(file)
Expand Down
7 changes: 0 additions & 7 deletions ext/standard/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,9 @@ php_meta_tags_token php_next_meta_token(php_meta_tags_data *);
typedef struct {
int pclose_ret;
size_t def_chunk_size;
bool auto_detect_line_endings;
zend_long default_socket_timeout;
zend_string *user_agent; /* for the http wrapper */
zend_string *from_address; /* for the ftp and http wrappers */
const char *user_stream_current_filename; /* for simple recursion protection */
php_stream_context *default_context;
HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */
HashTable *stream_filters; /* per-request copy of stream_filters_hash */
HashTable *wrapper_logged_errors; /* key: wrapper address; value: linked list of error entries */
php_stream_error_state stream_error_state;
int pclose_wait;
#ifdef HAVE_GETHOSTBYNAME_R
struct hostent tmp_host_info;
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/fsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
RETVAL_FALSE;

if (timeout_is_null) {
timeout = (double)FG(default_socket_timeout);
timeout = (double)PG(default_socket_timeout);
}

if (persistent) {
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/http_fopen_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
#endif
} else {
#ifndef PHP_WIN32
timeout.tv_sec = FG(default_socket_timeout);
timeout.tv_sec = PG(default_socket_timeout);
#else
timeout.tv_sec = (long)FG(default_socket_timeout);
timeout.tv_sec = (long)PG(default_socket_timeout);
#endif
timeout.tv_usec = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/streamsfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ PHP_FUNCTION(stream_socket_client)
RETVAL_FALSE;

if (timeout_is_null) {
timeout = (double)FG(default_socket_timeout);
timeout = (double)PG(default_socket_timeout);
} else if (!zend_finite(timeout)) {
zend_argument_value_error(4, "must be a finite value");
RETURN_THROWS();
Expand Down Expand Up @@ -290,7 +290,7 @@ PHP_FUNCTION(stream_socket_accept)
ZEND_PARSE_PARAMETERS_END();

if (timeout_is_null) {
timeout = (double)FG(default_socket_timeout);
timeout = (double)PG(default_socket_timeout);
} else if (!zend_finite(timeout)) {
zend_argument_value_error(2, "must be a finite value");
RETURN_THROWS();
Expand Down
17 changes: 17 additions & 0 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,15 @@ static PHP_INI_MH(OnChangeMailForceExtra)
}
/* }}} */

static PHP_INI_MH(OnUpdateAutoDetectLineEndings)
{
if (zend_ini_parse_bool(new_value)) {
zend_error(E_DEPRECATED, "auto_detect_line_endings is deprecated");
}
return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
}


/* defined in browscap.c */
PHP_INI_MH(OnChangeBrowscap);

Expand Down Expand Up @@ -919,6 +928,8 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("syslog.facility", "LOG_USER", PHP_INI_SYSTEM, OnSetFacility, syslog_facility, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("syslog.ident", "php", PHP_INI_SYSTEM, OnUpdateString, syslog_ident, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("syslog.filter", "no-ctrl", PHP_INI_ALL, OnSetLogFilter, syslog_filter, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("default_socket_timeout", "60", PHP_INI_ALL, OnUpdateLong, default_socket_timeout, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateAutoDetectLineEndings, auto_detect_line_endings, php_core_globals, core_globals)
PHP_INI_END()
/* }}} */

Expand Down Expand Up @@ -1871,6 +1882,12 @@ zend_result php_request_startup(void)
signal(SIGCHLD, sigchld_handler);
#endif

/* Default to global wrappers only */
PG(stream_wrappers) = NULL;

/* Default to global filters only */
PG(stream_filters) = NULL;

zend_try {
PG(in_error_log) = 0;
PG(during_request_startup) = 1;
Expand Down
2 changes: 1 addition & 1 deletion main/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ PHPAPI php_stream *_php_stream_sock_open_from_socket(php_socket_t socket, const
memset(sock, 0, sizeof(php_netstream_data_t));

sock->is_blocked = true;
sock->timeout.tv_sec = FG(default_socket_timeout);
sock->timeout.tv_sec = PG(default_socket_timeout);
sock->timeout.tv_usec = 0;
sock->socket = socket;

Expand Down
7 changes: 7 additions & 0 deletions main/php_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ struct _php_core_globals {
bool allow_url_fopen;
bool enable_post_data_reading;
bool report_zend_debug;
bool auto_detect_line_endings;

int last_error_type;
uint32_t last_error_lineno;
Expand Down Expand Up @@ -170,6 +171,12 @@ struct _php_core_globals {
char *syslog_ident;
zend_long syslog_filter;
zend_long error_log_mode;
zend_long default_socket_timeout;
const char *user_stream_current_filename; /* for simple recursion protection */
HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */
HashTable *stream_filters; /* per-request copy of stream_filters_hash */
HashTable *wrapper_logged_errors; /* key: wrapper address; value: linked list of error entries */
php_stream_error_state stream_error_state;
};


Expand Down
17 changes: 8 additions & 9 deletions main/streams/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@

#include "php.h"
#include "php_network.h"
#include "ext/standard/file.h" /* For FG(stream_filters) */
#include <stddef.h>
#include <fcntl.h>

#include "php_streams_int.h"

/* Global filter hash, copied to FG(stream_filters) on registration of volatile filter */
/* Global filter hash, copied to PG(stream_filters) on registration of volatile filter */
static HashTable stream_filters_hash;

/* Should only be used during core initialization */
Expand All @@ -32,7 +31,7 @@ PHPAPI HashTable *php_get_stream_filters_hash_global(void)
/* Normal hash selection/retrieval call */
PHPAPI HashTable *php_get_stream_filters_hash(void)
{
return (FG(stream_filters) ? FG(stream_filters) : &stream_filters_hash);
return (PG(stream_filters) ? PG(stream_filters) : &stream_filters_hash);
}

/* API for registering GLOBAL filters */
Expand All @@ -53,13 +52,13 @@ PHPAPI zend_result php_stream_filter_unregister_factory(const char *filterpatter
/* API for registering VOLATILE wrappers */
PHPAPI zend_result php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory)
{
if (!FG(stream_filters)) {
ALLOC_HASHTABLE(FG(stream_filters));
zend_hash_init(FG(stream_filters), zend_hash_num_elements(&stream_filters_hash) + 1, NULL, NULL, 0);
zend_hash_copy(FG(stream_filters), &stream_filters_hash, NULL);
if (!PG(stream_filters)) {
ALLOC_HASHTABLE(PG(stream_filters));
zend_hash_init(PG(stream_filters), zend_hash_num_elements(&stream_filters_hash) + 1, NULL, NULL, 0);
zend_hash_copy(PG(stream_filters), &stream_filters_hash, NULL);
}

return zend_hash_add_ptr(FG(stream_filters), filterpattern, (void*)factory) ? SUCCESS : FAILURE;
return zend_hash_add_ptr(PG(stream_filters), filterpattern, (void*)factory) ? SUCCESS : FAILURE;
}

/* Buckets */
Expand Down Expand Up @@ -216,7 +215,7 @@ PHPAPI void php_stream_bucket_unlink(php_stream_bucket *bucket)
* charsets (for example) but still be able to provide them all as filters */
PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval *filterparams, bool persistent)
{
HashTable *filter_hash = (FG(stream_filters) ? FG(stream_filters) : &stream_filters_hash);
HashTable *filter_hash = (PG(stream_filters) ? PG(stream_filters) : &stream_filters_hash);
const php_stream_filter_factory *factory = NULL;
php_stream_filter *filter = NULL;
size_t n;
Expand Down
Loading
Loading