From: Adam Dickmeiss Date: Tue, 3 Jan 2012 13:03:46 +0000 (+0100) Subject: Yet another fix for connection re-use X-Git-Tag: v1.6.8~12 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=21ee4d75995a96bd53f5531ca66669bfbdfd05ec;p=pazpar2-moved-to-github.git Yet another fix for connection re-use client_prep_connection returns 2 if connection was re-usable and only in that case will the result set be re-used - for same search. --- diff --git a/src/connection.c b/src/connection.c index f1ca36e..0b7a79b 100644 --- a/src/connection.c +++ b/src/connection.c @@ -526,13 +526,12 @@ int client_prep_connection(struct client *cl, { assert(co->host); if (co->host == host && client_get_state(cl) == Client_Idle) - ; /* reusing connection. It's ours! */ - else { - client_incref(cl); - connection_release(co); - co = 0; + return 2; } + client_incref(cl); + connection_release(co); + co = 0; } if (!co) { diff --git a/src/session.c b/src/session.c index 19ac45c..425d6ca 100644 --- a/src/session.c +++ b/src/session.c @@ -731,27 +731,24 @@ enum pazpar2_error_code session_search(struct session *se, no_failed_query++; else if (parse_ret == -2) no_failed_limit++; - else if (parse_ret == 0) - { - session_log(se, YLOG_LOG, "client NEW %s", client_get_id(cl)); - no_working++; - if (client_prep_connection(cl, se->service->z3950_operation_timeout, - se->service->z3950_session_timeout, - se->service->server->iochan_man, - &tval)) - client_start_search(cl); - } else { - session_log(se, YLOG_LOG, "client REUSE %s", client_get_id(cl)); - no_working++; - if (client_prep_connection(cl, se->service->z3950_operation_timeout, + int r = + client_prep_connection(cl, se->service->z3950_operation_timeout, se->service->z3950_session_timeout, se->service->server->iochan_man, - &tval)) + &tval); + if (parse_ret == 1 && r == 2) { + session_log(se, YLOG_LOG, "client REUSE %s", client_get_id(cl)); client_reingest(cl); } + else + { + session_log(se, YLOG_LOG, "client NEW %s", client_get_id(cl)); + client_start_search(cl); + } + no_working++; } } facet_limits_destroy(facet_limits);