]> granicus.if.org Git - php/commitdiff
Fix PostgreSQL startup routine in thread-safe mode
authorZeev Suraski <zeev@php.net>
Sat, 5 Feb 2000 17:26:35 +0000 (17:26 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 5 Feb 2000 17:26:35 +0000 (17:26 +0000)
ext/mssql/php_mssql.c
ext/mysql/php_mysql.c
ext/pgsql/pgsql.c
ext/pgsql/php_pgsql.h
main/php_ini.c
main/php_ini.h

index dfa3451c5b906f15db0bc851c25499df3afa18a4..d239080eb5e248f83ca39dc09c71e0be5ae2d5d4 100644 (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)
index b2ad027b02b2f494b1d7ed651a77c097283ba1b3..f02382d2fe35d4653cbdcb76037207438950a133 100644 (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)
index f95e1b0be8d570a42622517484ce14c25cec4e7c..63498028186f9838dd7b33e29ac10258b31b117c 100644 (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();
index ca4975458c3063e926699cbd71619444e715d56b..37dff8235b46ecb18add492054a527f8046316c7 100644 (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);
index 27ed9973a39e8bcadf756cba4f26936281c0ad04..5e5c5f876654604da28c3a0372e12de77d572399 100644 (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) {
index c805347ab8de61758a6b9e383e2aef50d5fc91a3..cc13ee468c36af4257a27913496b81d75ba7cd79 100644 (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 } };