From d7ba48e5055825167973cfa42ac76a7003f987bc Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 20 Sep 2007 08:13:26 +0000 Subject: [PATCH] Fixed bug #1628: show command returns zero hits when searching a slow target. The problem was that a client was in Client_Idle case when it was actually about to perform a search or other operation. The problem was in function client_prep_connection where a client state was set to CLient_Idle if connection was already open. This is wrong. The client is not idle: it is about to perform a search. A new client state is therefore needed: Client_Continue, which is like Client_Idle but differs in that a client is considered active. Neither Connecting or Connected are the same stage because these are states prior to Init Handshake with target. --- doc/pazpar2_protocol.xml | 4 ++-- src/client.c | 12 ++++++++---- src/client.h | 5 +++-- src/connection.c | 9 +++++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/doc/pazpar2_protocol.xml b/doc/pazpar2_protocol.xml index a4e208a..969093c 100644 --- a/doc/pazpar2_protocol.xml +++ b/doc/pazpar2_protocol.xml @@ -9,7 +9,7 @@ %idcommon; ]> - + Pazpar2 @@ -528,7 +528,7 @@ search.pz2?session=605047297&command=bytarget&id=3 The following client states are defined: Client_Connecting, Client_Connected, Client_Idle, Client_Initializing, Client_Searching, Client_Searching, Client_Presenting, Client_Error, Client_Failed, - Client_Disconnected, Client_Stopped. + Client_Disconnected, Client_Stopped, Client_Continue. diff --git a/src/client.c b/src/client.c index 048c95c..f42ec23 100644 --- a/src/client.c +++ b/src/client.c @@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.22 2007-09-19 13:23:35 adam Exp $ +/* $Id: client.c,v 1.23 2007-09-20 08:13:27 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -101,7 +101,8 @@ static const char *client_states[] = { "Client_Error", "Client_Failed", "Client_Disconnected", - "Client_Stopped" + "Client_Stopped", + "Client_Continue" }; static struct client *client_freelist = 0; @@ -817,7 +818,7 @@ void client_continue(struct client *cl) if (cl->state == Client_Connected) { client_init_request(cl); } - if (cl->state == Client_Idle) + if (cl->state == Client_Continue || cl->state == Client_Idle) { struct session *se = client_get_session(cl); if (cl->requestid != se->requestid && cl->pquery) { @@ -833,6 +834,8 @@ void client_continue(struct client *cl) cl->records < cl->hits) { client_send_present(cl); } + else + client_set_state(cl, Client_Idle); } } @@ -977,7 +980,8 @@ void client_set_session(struct client *cl, struct session *se) int client_is_active(struct client *cl) { - if (cl->connection && (cl->state == Client_Connecting || + if (cl->connection && (cl->state == Client_Continue || + cl->state == Client_Connecting || cl->state == Client_Initializing || cl->state == Client_Searching || cl->state == Client_Presenting)) diff --git a/src/client.h b/src/client.h index f9d5b64..ba40fc1 100644 --- a/src/client.h +++ b/src/client.h @@ -1,4 +1,4 @@ -/* $Id: client.h,v 1.3 2007-06-15 19:35:17 adam Exp $ +/* $Id: client.h,v 1.4 2007-09-20 08:13:27 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -40,7 +40,8 @@ enum client_state Client_Error, Client_Failed, Client_Disconnected, - Client_Stopped + Client_Stopped, + Client_Continue }; int client_show_raw_begin(struct client *cl, int position, diff --git a/src/connection.c b/src/connection.c index 149709a..a8c9f20 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1,4 +1,4 @@ -/* $Id: connection.c,v 1.11 2007-08-28 21:11:21 quinn Exp $ +/* $Id: connection.c,v 1.12 2007-09-20 08:13:27 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -261,7 +261,7 @@ static void connection_handler(IOCHAN i, int event) else // we throw away response and go to idle mode { yaz_log(YLOG_DEBUG, "Ignoring result of expired operation"); - client_set_state(cl, Client_Idle); + client_set_state(cl, Client_Continue); } } /* if len==1 we do nothing but wait for more input */ @@ -477,8 +477,9 @@ int client_prep_connection(struct client *cl) else if (co->state == Conn_Open) { if (client_get_state(cl) == Client_Error - || client_get_state(cl) == Client_Disconnected) - client_set_state(cl, Client_Idle); + || client_get_state(cl) == Client_Disconnected + || client_get_state(cl) == Client_Idle) + client_set_state(cl, Client_Continue); iochan_setflag(co->iochan, EVENT_OUTPUT); } return 1; -- 1.7.10.4