#include <yaz/yaz-ccl.h>
#include <yaz/zoom.h>
-#define MAX_ASSOC 100
+#define MAX_ASSOC 200
typedef struct Yaz_AssociationInfo *Yaz_Association;
int in_use;
int order;
int zval_resource;
+ long time_stamp;
};
static Yaz_Association yaz_association_mk()
p->persistent = 0;
p->ccl_parser = ccl_parser_create();
p->ccl_parser->bibset = 0;
+ p->time_stamp = 0;
return p;
}
as->in_use = 1;
as->persistent = persistent;
as->order = YAZSG(assoc_seq);
-
+ as->time_stamp = time(0);
#ifdef ZTS
tsrm_mutex_unlock (yaz_mutex);
#endif
STD_PHP_INI_ENTRY("yaz.max_links", "100", PHP_INI_ALL, OnUpdateLong, max_links, zend_yaz_globals, yaz_globals)
#else
STD_PHP_INI_ENTRY("yaz.max_links", "100", PHP_INI_ALL, OnUpdateInt, max_links, zend_yaz_globals, yaz_globals)
+#endif
+#if PHP_MAJOR_VERSION >= 5
+ STD_PHP_INI_ENTRY("yaz.keepalive", "120", PHP_INI_ALL, OnUpdateLong, keepalive, zend_yaz_globals, yaz_globals)
+#else
+ STD_PHP_INI_ENTRY("yaz.keepalive", "120", PHP_INI_ALL, OnUpdateInt, keepalive, zend_yaz_globals, yaz_globals)
#endif
STD_PHP_INI_ENTRY("yaz.log_file", NULL, PHP_INI_ALL, OnUpdateString, log_file, zend_yaz_globals, yaz_globals)
PHP_INI_END()
PHP_RSHUTDOWN_FUNCTION(yaz)
{
+ long now = time(0);
+ int i;
+
+ yaz_log(LOG_LOG, "rshutdown keepalive=%ld", YAZSG(keepalive));
+#ifdef ZTS
+ tsrm_mutex_lock(yaz_mutex);
+#endif
+ for (i = 0; i < YAZSG(max_links); i++) {
+ Yaz_Association *as = shared_associations + i;
+ if (*as)
+ {
+ if (now - (*as)->time_stamp > YAZSG(keepalive))
+ {
+ const char *host = option_get(*as, "host");
+ if (host)
+ yaz_log(LOG_LOG, "shutdown of %s", host);
+
+ yaz_association_destroy(*as);
+ *as = 0;
+ }
+ }
+ }
+#ifdef ZTS
+ tsrm_mutex_unlock(yaz_mutex);
+#endif
return SUCCESS;
}