From: Adam Dickmeiss Date: Thu, 11 Jul 2002 13:04:03 +0000 (+0000) Subject: yaz.max_links, yaz_log_file setting. User-defined Other Info X-Git-Tag: dev~357 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c19790778d391253dc9fb0d6895089714a8a47f;p=php yaz.max_links, yaz_log_file setting. User-defined Other Info --- diff --git a/ext/yaz/php_yaz.c b/ext/yaz/php_yaz.c index a5abc4b4a8..47b2d39ba0 100644 --- a/ext/yaz/php_yaz.c +++ b/ext/yaz/php_yaz.c @@ -23,6 +23,7 @@ #endif #include "php.h" +#include "php_ini.h" #if HAVE_YAZ @@ -326,7 +327,6 @@ static void get_assoc (INTERNAL_FUNCTION_PARAMETERS, pval **id, Yaz_Association *assocp) { Yaz_Association *as = 0; - YAZSLS_FETCH(); *assocp = 0; #ifdef ZTS @@ -1101,7 +1101,6 @@ static int do_event (int *id, int timeout) int no = 0; int max_fd = 0; struct timeval tv; - YAZSLS_FETCH(); tv.tv_sec = timeout; tv.tv_usec = 0; @@ -1111,7 +1110,7 @@ static int do_event (int *id, int timeout) #endif FD_ZERO (&input); FD_ZERO (&output); - for (i = 0; i < MAX_ASSOC; i++) + for (i = 0; i < YAZSG(max_links); i++) { Yaz_Association p = shared_associations[i]; int fd; @@ -1140,7 +1139,7 @@ static int do_event (int *id, int timeout) #ifdef ZTS tsrm_mutex_lock (yaz_mutex); #endif - for (i = 0; izoom_conn, zurl_str, 0); break; } @@ -1290,13 +1295,13 @@ PHP_FUNCTION(yaz_connect) break; #endif } - if (i == MAX_ASSOC) + if (i == YAZSG(max_links)) { /* we didn't have it (or already in use) */ int i0 = -1; int min_order = 2000000000; /* find completely free slot or the oldest one */ - for (i = 0; iin_use && as->order < min_order) @@ -1305,7 +1310,7 @@ PHP_FUNCTION(yaz_connect) i0 = i; } } - if (i == MAX_ASSOC) + if (i == YAZSG(max_links)) { i = i0; if (i == -1) @@ -1325,6 +1330,11 @@ PHP_FUNCTION(yaz_connect) option_set (as, "pass", pass_str); option_set (as, "cookie", cookie_str); option_set (as, "clientIP", client_IP); + + option_set (as, "otherInfo0", otherInfo[0]); + option_set (as, "otherInfo1", otherInfo[1]); + option_set (as, "otherInfo2", otherInfo[2]); + ZOOM_connection_connect (as->zoom_conn, zurl_str, 0); #else as->host_port = xstrdup (zurl_str); @@ -1524,7 +1534,6 @@ PHP_FUNCTION(yaz_wait) ZOOM_connection conn_ar[MAX_ASSOC]; #endif int i, id, timeout = 15; - YAZSLS_FETCH(); if (ZEND_NUM_ARGS() == 1) { @@ -1548,7 +1557,7 @@ PHP_FUNCTION(yaz_wait) #ifdef ZTS tsrm_mutex_lock (yaz_mutex); #endif - for (i = 0; iorder == YAZSG(assoc_seq)) { if ((*as)->persistent) @@ -2990,6 +2997,18 @@ static void yaz_close_link (zend_rsrc_list_entry *rsrc yaz_close_session (as); } +/* {{{ PHP_INI_BEGIN + */ +PHP_INI_BEGIN() + STD_PHP_INI_ENTRY("yaz.max_links", "100", PHP_INI_ALL, + OnUpdateInt, max_links, + zend_yaz_globals, yaz_globals) + STD_PHP_INI_ENTRY("yaz.log_file", "", PHP_INI_ALL, + OnUpdateString, log_file, + zend_yaz_globals, yaz_globals) + PHP_INI_END() +/* }}} */ + PHP_MINIT_FUNCTION(yaz) { int i; @@ -2997,8 +3016,16 @@ PHP_MINIT_FUNCTION(yaz) #ifdef ZTS yaz_mutex = tsrm_mutex_alloc(); #endif + yaz_log_init_file ("/dev/null"); ZEND_INIT_MODULE_GLOBALS(yaz, php_yaz_init_globals, NULL); + REGISTER_INI_ENTRIES(); + + if (YAZSG(log_file)) + { + yaz_log_init_file(YAZSG(log_file)); + yaz_log_init_level (LOG_ALL); + } le_link = zend_register_list_destructors_ex (yaz_close_link, 0, "YAZ link", module_number); order_associations = 1; @@ -3031,6 +3058,9 @@ PHP_MINFO_FUNCTION(yaz) php_info_print_table_start(); php_info_print_table_row(2, "YAZ Support", "enabled"); php_info_print_table_row(2, "YAZ Version", YAZ_VERSION); +#if USE_ZOOM + php_info_print_table_row(2, "ZOOM", "enabled"); +#endif php_info_print_table_end(); } @@ -3041,7 +3071,8 @@ PHP_RSHUTDOWN_FUNCTION(yaz) PHP_RINIT_FUNCTION(yaz) { - YAZSLS_FETCH(); + char pidstr[20]; + sprintf (pidstr, "%ld", (long) getpid()); #ifdef ZTS tsrm_mutex_lock (yaz_mutex); #endif @@ -3049,6 +3080,7 @@ PHP_RINIT_FUNCTION(yaz) #ifdef ZTS tsrm_mutex_unlock (yaz_mutex); #endif + yaz_log_init_prefix(pidstr); return SUCCESS; } diff --git a/ext/yaz/php_yaz.h b/ext/yaz/php_yaz.h index 4e6f0cb147..0a80be2f2b 100644 --- a/ext/yaz/php_yaz.h +++ b/ext/yaz/php_yaz.h @@ -55,22 +55,14 @@ PHP_FUNCTION(yaz_schema); ZEND_BEGIN_MODULE_GLOBALS(yaz) int assoc_seq; + int max_links; + char *log_file; ZEND_END_MODULE_GLOBALS(yaz) - + #ifdef ZTS -# define YAZSLS_D zend_mysql_globals *yaz_globals -# define YAZSLS_DC , YAZSLS_D -# define YAZSLS_C yaz_globals -# define YAZSLS_CC , YAZSLS_C -# define YAZSG(v) (yaz_globals->v) -# define YAZSLS_FETCH() zend_yaz_globals *yaz_globals = ts_resource(yaz_globals_id) +#define YAZSG(v) TSRMG(yaz_globals_id, zend_yaz_globals *. v) #else -# define YAZSLS_D -# define YAZSLS_DC -# define YAZSLS_C -# define YAZSLS_CC -# define YAZSG(v) (yaz_globals.v) -# define YAZSLS_FETCH() +#define YAZSG(v) (yaz_globals.v) #endif #else