Fix PostgreSQL startup routine in thread-safe mode

This commit is contained in:
Zeev Suraski 2000-02-05 17:26:35 +00:00
parent bf609338ae
commit 39cb8fe0ac
6 changed files with 42 additions and 52 deletions

View file

@ -83,26 +83,6 @@ DLEXPORT zend_module_entry *get_module(void) { return &mssql_module_entry; };
#define CHECK_LINK(link) { if (link==-1) { php_error(E_WARNING,"MS SQL: A link to the server could not be established"); RETURN_FALSE; } }
static PHP_INI_DISP(display_link_numbers)
{
char *value;
if (type==PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ini_entry->orig_value;
} else if (ini_entry->value) {
value = ini_entry->value;
} else {
value = NULL;
}
if (value) {
if (atoi(value)==-1) {
PUTS("Unlimited");
} else {
php_printf("%s", value);
}
}
}
PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("mssql.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_persistent, php_mssql_globals, mssql_globals)

View file

@ -255,28 +255,6 @@ static PHP_INI_MH(OnMySQLPort)
}
static PHP_INI_DISP(display_link_numbers)
{
char *value;
if (type==PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ini_entry->orig_value;
} else if (ini_entry->value) {
value = ini_entry->value;
} else {
value = NULL;
}
if (value) {
if (atoi(value)==-1) {
PUTS("Unlimited");
} else {
php_printf("%s", value);
}
}
}
PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("mysql.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateInt, allow_persistent, php_mysql_globals, mysql_globals)
STD_PHP_INI_ENTRY_EX("mysql.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_persistent, php_mysql_globals, mysql_globals, display_link_numbers)

View file

@ -26,6 +26,7 @@
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/php_standard.h"
#include "php_pgsql.h"
#include "php_globals.h"
@ -75,7 +76,7 @@ function_entry pgsql_functions[] = {
};
zend_module_entry pgsql_module_entry = {
"PostgreSQL", pgsql_functions, PHP_MINIT(pgsql), NULL, PHP_RINIT(pgsql), NULL, NULL, STANDARD_MODULE_PROPERTIES
"PostgreSQL", pgsql_functions, PHP_MINIT(pgsql), PHP_MSHUTDOWN(pgsql), PHP_RINIT(pgsql), NULL, NULL, STANDARD_MODULE_PROPERTIES
};
#if COMPILE_DL
@ -121,18 +122,16 @@ static void _free_result(pgsql_result_handle *pg_result)
efree(pg_result);
}
PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("pgsql.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateInt, allow_persistent, php_pgsql_globals, pgsql_globals)
STD_PHP_INI_ENTRY_EX("pgsql.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_persistent, php_pgsql_globals, pgsql_globals, display_link_numbers)
STD_PHP_INI_ENTRY_EX("pgsql.max_links", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_links, php_pgsql_globals, pgsql_globals, display_link_numbers)
PHP_INI_END()
static void php_pgsql_init_globals(PGLS_D)
{
PGG(num_persistent) = 0;
if (cfg_get_long("pgsql.allow_persistent",&PGG(allow_persistent))==FAILURE) {
PGG(allow_persistent)=1;
}
if (cfg_get_long("pgsql.max_persistent",&PGG(max_persistent))==FAILURE) {
PGG(max_persistent)=-1;
}
if (cfg_get_long("pgsql.max_links",&PGG(max_links))==FAILURE) {
PGG(max_links)=-1;
}
}
PHP_MINIT_FUNCTION(pgsql)
@ -142,6 +141,8 @@ PHP_MINIT_FUNCTION(pgsql)
#else
php_pgsql_init_globals(PGLS_C);
#endif
REGISTER_INI_ENTRIES();
le_link = register_list_destructors(_close_pgsql_link,NULL);
le_plink = register_list_destructors(NULL,_close_pgsql_plink);
@ -158,6 +159,13 @@ PHP_MINIT_FUNCTION(pgsql)
}
PHP_MSHUTDOWN_FUNCTION(pgsql)
{
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
PHP_RINIT_FUNCTION(pgsql)
{
PGLS_FETCH();

View file

@ -59,6 +59,7 @@ extern zend_module_entry pgsql_module_entry;
#endif
PHP_MINIT_FUNCTION(pgsql);
PHP_MSHUTDOWN_FUNCTION(pgsql);
PHP_RINIT_FUNCTION(pgsql);
PHP_FUNCTION(pg_connect);
PHP_FUNCTION(pg_pconnect);

View file

@ -331,6 +331,28 @@ PHP_INI_DISP(php_ini_color_displayer_cb)
}
PHP_INI_DISP(display_link_numbers)
{
char *value;
if (type==PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ini_entry->orig_value;
} else if (ini_entry->value) {
value = ini_entry->value;
} else {
value = NULL;
}
if (value) {
if (atoi(value)==-1) {
PUTS("Unlimited");
} else {
php_printf("%s", value);
}
}
}
static int php_ini_displayer(php_ini_entry *ini_entry, int module_number)
{
if (ini_entry->module_number != module_number) {

View file

@ -70,6 +70,7 @@ php_ini_entry *get_ini_entry(char *name, uint name_length);
PHPAPI int php_ini_register_displayer(char *name, uint name_length, void (*displayer)(php_ini_entry *ini_entry, int type));
PHPAPI PHP_INI_DISP(php_ini_boolean_displayer_cb);
PHPAPI PHP_INI_DISP(php_ini_color_displayer_cb);
PHPAPI PHP_INI_DISP(display_link_numbers);
#define PHP_INI_BEGIN() static php_ini_entry ini_entries[] = {
#define PHP_INI_END() { 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, NULL } };