From 77ba2b539f5e7e74af67194b7f78a55cf7310edc Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 6 Mar 2015 14:13:03 +0100 Subject: [PATCH] Re-factor: move work in client_check_preferred_watch to client_got_records --- src/client.c | 26 +++++--------------------- src/client.h | 1 - src/connection.c | 3 --- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/client.c b/src/client.c index ad2d2a3..dac30f2 100644 --- a/src/client.c +++ b/src/client.c @@ -543,27 +543,6 @@ static void ingest_raw_record(struct client *cl, ZOOM_record rec) client_show_raw_dequeue(cl); } -void client_check_preferred_watch(struct client *cl) -{ - struct session *se = cl->session; - yaz_log(YLOG_DEBUG, "client_check_preferred_watch: %s ", client_get_id(cl)); - if (se) - { - client_unlock(cl); - /* TODO possible threading issue. Session can have been destroyed */ - if (session_is_preferred_clients_ready(se)) { - session_alert_watch(se, SESSION_WATCH_SHOW_PREF); - } - else - yaz_log(YLOG_DEBUG, "client_check_preferred_watch: Still locked on preferred targets."); - - client_lock(cl); - } - else - yaz_log(YLOG_WARN, "client_check_preferred_watch: %s. No session!", client_get_id(cl)); - -} - struct suggestions* client_suggestions_create(const char* suggestions_string); static void client_suggestions_destroy(struct client *cl); @@ -603,6 +582,11 @@ void client_got_records(struct client *cl) struct session *se = cl->session; if (se) { + client_unlock(cl); + /* TODO possible threading issue. Session can have been destroyed */ + if (session_is_preferred_clients_ready(se)) + session_alert_watch(se, SESSION_WATCH_SHOW_PREF); + client_lock(cl); if (reclist_get_num_records(se->reclist) > 0) { client_unlock(cl); diff --git a/src/client.h b/src/client.h index 6092dfa..e124ac4 100644 --- a/src/client.h +++ b/src/client.h @@ -104,7 +104,6 @@ void client_unlock(struct client *c); void client_stop(struct client *c); int client_has_facet(struct client *cl, const char *name); -void client_check_preferred_watch(struct client *cl); int client_reingest(struct client *cl); const char *client_get_facet_limit_local(struct client *cl, struct session_database *sdb, diff --git a/src/connection.c b/src/connection.c index c52fcf3..a25d840 100644 --- a/src/connection.c +++ b/src/connection.c @@ -274,10 +274,7 @@ static void non_block_events(struct connection *co) { struct client *cl = co->client; if (cl) - { - client_check_preferred_watch(cl); client_got_records(cl); - } } } -- 1.7.10.4