From eae6eee32de3560f84a83ee5cc922a2d3d63cc44 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 11 Mar 2010 12:41:59 +0100 Subject: [PATCH] Release record block on show after first chunk The client and connection code now fires SESSION_WATCH_SHOW and SESSION_WATCH_RECORD after all non-blocking events has been received from some client. Previously this was done on first record received. Fixes #3318. --- src/client.c | 14 +++++++++----- src/client.h | 2 +- src/connection.c | 12 ++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/client.c b/src/client.c index b4d323e..7e1645a 100644 --- a/src/client.c +++ b/src/client.c @@ -417,6 +417,15 @@ void client_search_response(struct client *cl) } } +void client_got_records(struct client *cl) +{ + if (cl->session) + { + session_alert_watch(cl->session, SESSION_WATCH_SHOW); + session_alert_watch(cl->session, SESSION_WATCH_RECORD); + } +} + void client_record_response(struct client *cl) { struct connection *co = cl->connection; @@ -478,11 +487,6 @@ void client_record_response(struct client *cl) if (ingest_record(cl, xmlrec, cl->record_offset, nmem)) yaz_log(YLOG_WARN, "Failed to ingest from %s", client_get_url(cl)); - else - { - session_alert_watch(cl->session, SESSION_WATCH_SHOW); - session_alert_watch(cl->session, SESSION_WATCH_RECORD); - } } nmem_destroy(nmem); } diff --git a/src/client.h b/src/client.h index 7eedec8..e746efa 100644 --- a/src/client.h +++ b/src/client.h @@ -91,7 +91,7 @@ void client_set_maxrecs(struct client *cl, int v); void client_set_startrecs(struct client *cl, int v); void client_remove_from_session(struct client *c); void client_incref(struct client *c); - +void client_got_records(struct client *c); #endif /* diff --git a/src/connection.c b/src/connection.c index 3fb061b..1525dfb 100644 --- a/src/connection.c +++ b/src/connection.c @@ -159,6 +159,7 @@ static struct connection *connection_create(struct client *cl, static void non_block_events(struct connection *co) { + int got_records = 0; IOCHAN iochan = co->iochan; ZOOM_connection link = co->link; while (1) @@ -213,6 +214,7 @@ static void non_block_events(struct connection *co) break; case ZOOM_EVENT_RECV_RECORD: client_record_response(cl); + got_records = 1; break; default: yaz_log(YLOG_LOG, "Unhandled event (%d) from %s", @@ -220,6 +222,16 @@ static void non_block_events(struct connection *co) } client_destroy(cl); } + if (got_records) + { + struct client *cl = co->client; + if (cl) + { + client_incref(cl); + client_got_records(cl); + client_destroy(cl); + } + } } void connection_continue(struct connection *co) -- 1.7.10.4