From: Adam Dickmeiss Date: Mon, 16 Jan 2012 15:18:28 +0000 (+0100) Subject: For sort, re-use non-idle clients X-Git-Tag: v1.6.8~6 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=116eaa2065a4b4fec0dcc55985170e3364132995;p=pazpar2-moved-to-github.git For sort, re-use non-idle clients But not for search where only IDLE clients are re-used. --- diff --git a/src/client.h b/src/client.h index 7971408..7a840b1 100644 --- a/src/client.h +++ b/src/client.h @@ -77,7 +77,8 @@ void client_disconnect(struct client *cl); int client_prep_connection(struct client *cl, int operation_timeout, int session_timeout, iochan_man_t iochan, - const struct timeval *abstime); + const struct timeval *abstime, + int ok_with_working); void client_start_search(struct client *cl); void client_set_session(struct client *cl, struct session *se); int client_is_active(struct client *cl); diff --git a/src/connection.c b/src/connection.c index e441514..02509cf 100644 --- a/src/connection.c +++ b/src/connection.c @@ -496,7 +496,8 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man) int client_prep_connection(struct client *cl, int operation_timeout, int session_timeout, iochan_man_t iochan_man, - const struct timeval *abstime) + const struct timeval *abstime, + int ok_with_working) { struct connection *co; struct session_database *sdb = client_get_database(cl); @@ -525,7 +526,8 @@ int client_prep_connection(struct client *cl, if (co) { assert(co->host); - if (co->host == host && client_get_state(cl) == Client_Idle) + if (co->host == host && (client_get_state(cl) == Client_Idle + || ok_with_working)) { return 2; } diff --git a/src/session.c b/src/session.c index 4beed61..78aad61 100644 --- a/src/session.c +++ b/src/session.c @@ -649,10 +649,11 @@ void session_sort(struct session *se, const char *field, int increasing) { struct client *cl = l->client; struct timeval tval; - if (client_prep_connection(cl, se->service->z3950_operation_timeout, - se->service->z3950_session_timeout, - se->service->server->iochan_man, - &tval)) + int ret = client_prep_connection(cl, se->service->z3950_operation_timeout, + se->service->z3950_session_timeout, + se->service->server->iochan_man, + &tval, 1); + if (ret) client_start_search(cl); } session_leave(se); @@ -743,7 +744,7 @@ enum pazpar2_error_code session_search(struct session *se, client_prep_connection(cl, se->service->z3950_operation_timeout, se->service->z3950_session_timeout, se->service->server->iochan_man, - &tval); + &tval, 0); if (parse_ret == 1 && r == 2) { session_log(se, YLOG_LOG, "client REUSE %s", client_get_id(cl));