From 6aed90d2cb69a71e6510475982d56933fb401606 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 9 Jan 2012 12:11:58 +0100 Subject: [PATCH] Skip incoming results from inactive clients For search with a filter an existing clients that are active and becomes filtered out (inactive, but cached) Pazpar2 would still accept record ingestion .. This patch fixes that. We mark session=0 in clients that are not selected for a search (not active, but cached). --- src/session.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/session.c b/src/session.c index 425d6ca..f7f687d 100644 --- a/src/session.c +++ b/src/session.c @@ -523,13 +523,14 @@ static void select_targets_callback(struct session *se, { cl = client_create(db->database->id); client_set_database(cl, db); - client_set_session(cl, se); l = xmalloc(sizeof(*l)); l->client = cl; l->next = se->clients_cached; se->clients_cached = l; } + /* set session always. If may be 0 if client is not active */ + client_set_session(cl, se); l = xmalloc(sizeof(*l)); l->client = cl; @@ -550,6 +551,11 @@ static void session_reset_active_clients(struct session *se, while (l) { struct client_list *l_next = l->next; + + client_lock(l->client); + client_set_session(l->client, 0); /* mark client inactive */ + client_unlock(l->client); + xfree(l); l = l_next; } -- 1.7.10.4