cvs: php4 /ext/yaz php_yaz.c php_yaz.h

From: Date: Thu, 11 Jul 2002 13:04:02 +0000
Subject: cvs: php4 /ext/yaz php_yaz.c php_yaz.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12782@lists.php.net to get a copy of this message
dickmeiss Thu Jul 11 09:04:02 2002 EDT Modified files: /php4/ext/yaz php_yaz.c php_yaz.h Log: yaz.max_links, yaz_log_file setting. User-defined Other Info Index: php4/ext/yaz/php_yaz.c diff -u php4/ext/yaz/php_yaz.c:1.44 php4/ext/yaz/php_yaz.c:1.45 --- php4/ext/yaz/php_yaz.c:1.44 Sun Jun 2 17:59:54 2002 +++ php4/ext/yaz/php_yaz.c Thu Jul 11 09:04:02 2002 @@ -16,13 +16,14 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_yaz.c,v 1.44 2002/06/02 21:59:54 dickmeiss Exp $ */ +/* $Id: php_yaz.c,v 1.45 2002/07/11 13:04:02 dickmeiss Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" +#include "php_ini.h" #if HAVE_YAZ @@ -326,7 +327,6 @@ Yaz_Association *assocp) { Yaz_Association *as = 0; - YAZSLS_FETCH(); *assocp = 0; #ifdef ZTS @@ -1101,7 +1101,6 @@ int no = 0; int max_fd = 0; struct timeval tv; - YAZSLS_FETCH(); tv.tv_sec = timeout; tv.tv_usec = 0; @@ -1111,7 +1110,7 @@ #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 @@ #ifdef ZTS tsrm_mutex_lock (yaz_mutex); #endif - for (i = 0; i<MAX_ASSOC; i++) + for (i = 0; i<YAZSG(max_links); i++) { int fd; Yaz_Association p = shared_associations[i]; @@ -1209,12 +1208,13 @@ const char *user_str = 0, *group_str = 0, *pass_str = 0; const char *cookie_str = 0, *proxy_str = 0; const char *client_IP = 0; + const char *otherInfo[3]; int persistent = 1; int piggyback = 1; pval **zurl, **user = 0; Yaz_Association as; - YAZSLS_FETCH(); + otherInfo[0] = otherInfo[1] = otherInfo[2] = 0; if (ZEND_NUM_ARGS() == 1) { if (zend_get_parameters_ex (1, &zurl) == FAILURE) @@ -1241,7 +1241,9 @@ piggyback_val = array_lookup_bool(ht, "piggyback"); if (piggyback_val) piggyback = *piggyback_val; - client_IP = array_lookup_string(ht, "clientIP"); + otherInfo[0] = array_lookup_string(ht, "otherInfo0"); + otherInfo[1] = array_lookup_string(ht, "otherInfo1"); + otherInfo[2] = array_lookup_string(ht, "otherInfo2"); } else { @@ -1264,7 +1266,7 @@ #ifdef ZTS tsrm_mutex_lock (yaz_mutex); #endif - for (i = 0; i<MAX_ASSOC; i++) + for (i = 0; i<YAZSG(max_links); i++) { as = shared_associations[i]; #if USE_ZOOM @@ -1276,6 +1278,9 @@ !strcmp_null(option_get(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); break; } @@ -1290,13 +1295,13 @@ 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; i<MAX_ASSOC && shared_associations[i]; i++) + for (i = 0; i<YAZSG(max_links) && shared_associations[i]; i++) { as = shared_associations[i]; if (persistent && !as->in_use && as->order < min_order) @@ -1305,7 +1310,7 @@ i0 = i; } } - if (i == MAX_ASSOC) + if (i == YAZSG(max_links)) { i = i0; if (i == -1) @@ -1325,6 +1330,11 @@ 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 @@ ZOOM_connection conn_ar[MAX_ASSOC]; #endif int i, id, timeout = 15; - YAZSLS_FETCH(); if (ZEND_NUM_ARGS() == 1) { @@ -1548,7 +1557,7 @@ #ifdef ZTS tsrm_mutex_lock (yaz_mutex); #endif - for (i = 0; i<MAX_ASSOC; i++) + for (i = 0; i<YAZSG(max_links); i++) { #if USE_ZOOM Yaz_Association p = shared_associations[i]; @@ -2966,8 +2975,6 @@ void yaz_close_session(Yaz_Association *as) { - YAZSLS_FETCH(); - if (*as && (*as)->order == YAZSG(assoc_seq)) { if ((*as)->persistent) @@ -2990,6 +2997,18 @@ 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 @@ #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_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_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 @@ #ifdef ZTS tsrm_mutex_unlock (yaz_mutex); #endif + yaz_log_init_prefix(pidstr); return SUCCESS; } Index: php4/ext/yaz/php_yaz.h diff -u php4/ext/yaz/php_yaz.h:1.11 php4/ext/yaz/php_yaz.h:1.12 --- php4/ext/yaz/php_yaz.h:1.11 Thu Feb 28 03:27:01 2002 +++ php4/ext/yaz/php_yaz.h Thu Jul 11 09:04:02 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_yaz.h,v 1.11 2002/02/28 08:27:01 sebastian Exp $ */ +/* $Id: php_yaz.h,v 1.12 2002/07/11 13:04:02 dickmeiss Exp $ */ #ifndef PHP_YAZ_H #define PHP_YAZ_H @@ -55,22 +55,14 @@ 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

« previous php.cvs (#12782) next »