struct database_criterion *next;
};
-
struct database_hosts {
struct host *hosts;
YAZ_MUTEX mutex;
};
// Create a new host structure for hostport
-static struct host *create_host(const char *hostport, iochan_man_t iochan_man)
+static struct host *create_host(const char *hostport)
{
struct host *host;
+ char *db_comment;
host = xmalloc(sizeof(struct host));
host->hostport = xstrdup(hostport);
+ db_comment = strchr(host->hostport, '#');
+ if (db_comment)
+ *db_comment = '\0';
host->connections = 0;
- host->ipport = 0;
host->mutex = 0;
- if (host_getaddrinfo(host, iochan_man))
- {
- xfree(host->hostport);
- xfree(host);
- return 0;
- }
pazpar2_mutex_create(&host->mutex, "host");
yaz_cond_create(&host->cond_ready);
}
static struct host *find_host(database_hosts_t hosts,
- const char *hostport, iochan_man_t iochan_man)
+ const char *hostport)
{
struct host *p;
yaz_mutex_enter(hosts->mutex);
break;
if (!p)
{
- p = create_host(hostport, iochan_man);
+ p = create_host(hostport);
if (p)
{
p->next = hosts->hosts;
if (db->host == 0)
{
struct host *host;
- char *p;
- char hostport[256];
- strcpy(hostport, db->url);
- if ((p = strchr(hostport, '/')))
- *p = '\0';
- if (!(host = find_host(service->server->database_hosts,
- hostport, service->server->iochan_man)))
+ if (!(host = find_host(service->server->database_hosts, db->url)))
return -1;
db->host = host;
}
struct database *new_database(const char *id, NMEM nmem)
{
struct database *db;
- char hostport[256];
- char *dbname;
- char *db_comment;
struct setting *idset;
- if (strlen(id) > 255)
- return 0;
- strcpy(hostport, id);
- if ((dbname = strchr(hostport, '/')))
- *(dbname++) = '\0';
- else
- dbname = "";
- db_comment = strchr(dbname, '#');
- if (db_comment)
- *db_comment = '\0';
db = nmem_malloc(nmem, sizeof(*db));
memset(db, 0, sizeof(*db));
- db->host = 0;
+
db->url = nmem_strdup(nmem, id);
- db->databases = nmem_malloc(nmem, 2 * sizeof(char *));
- db->databases[0] = nmem_strdup(nmem, dbname);
- db->databases[1] = 0;
db->errors = 0;
- db->explain = 0;
+ db->host = 0;
db->num_settings = PZ_MAX_EOF;
db->settings = nmem_malloc(nmem, sizeof(struct settings*) *
struct conf_service *service)
{
struct database *db;
- struct zr_explain *explain = 0;
db = new_database(id, service->nmem);
- db->explain = explain;
+
db->next = service->databases;
service->databases = db;
// Cycles through databases, calling a handler function on the ones for
// which all criteria matched.
int session_grep_databases(struct session *se, const char *filter,
- void (*fun)(void *context, struct session_database *db))
+ void (*fun)(struct session *se, struct session_database *db))
{
struct session_database *p;
NMEM nmem = nmem_create();
struct host *p_next = p->next;
yaz_mutex_destroy(&p->mutex);
yaz_cond_destroy(&p->cond_ready);
- xfree(p->ipport);
xfree(p->hostport);
xfree(p);
p = p_next;