X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fclient.c;h=39140a770eecfaf71bf100b73be2904f372a4730;hb=87e9791ee9a652b3665d59ca5bf0e927e935e666;hp=5f05633bdf77041e25ba98283d69f0de60f005c7;hpb=0198d9a410e2664e29f8fa526cf9bcf8f5bea89a;p=pazpar2-moved-to-github.git diff --git a/src/client.c b/src/client.c index 5f05633..39140a7 100644 --- a/src/client.c +++ b/src/client.c @@ -115,6 +115,7 @@ struct client { char *addinfo; // diagnostic info for most resent error Odr_int hits; int record_offset; + int show_stat_no; int filtered; // When using local:, this will count the number of filtered records. int maxrecs; int startrecs; @@ -762,21 +763,55 @@ static const char *get_strategy_plus_sort(struct client *l, const char *field) return strategy_plus_sort; } +void client_update_show_stat(struct client *cl, int cmd) +{ + if (cmd == 0) + cl->show_stat_no = 0; + else if (cmd == 1) + cl->show_stat_no++; +} + int client_fetch_more(struct client *cl) { - int extra = cl->hits - cl->record_offset; - if (extra > 0) + struct session_database *sdb = client_get_database(cl); + const char *str; + int extend_recs = 0; + int number; + + yaz_log(YLOG_LOG, "cl=%s show_stat_no=%d got=%d", + client_get_id(cl), cl->show_stat_no, cl->record_offset); + if (cl->show_stat_no < cl->record_offset) + return 0; + yaz_log(YLOG_LOG, "cl=%s Trying to get more", client_get_id(cl)); + + str = session_setting_oneval(sdb, PZ_EXTENDRECS); + if (str && *str) + extend_recs = atoi(str); + + if (extend_recs > cl->hits) + extend_recs = cl->hits; + + number = extend_recs - cl->record_offset; + if (number > 0) { ZOOM_resultset set = cl->resultset; - int max_extra = 10; + struct connection *co = client_get_connection(cl); - if (extra > max_extra) - extra = max_extra; + str = session_setting_oneval(sdb, PZ_REQUESTSYNTAX); + ZOOM_resultset_option_set(set, "preferredRecordSyntax", str); + str = session_setting_oneval(sdb, PZ_ELEMENTS); + if (str && *str) + ZOOM_resultset_option_set(set, "elementSetName", str); - ZOOM_resultset_records(set, 0, cl->record_offset, extra); + ZOOM_resultset_records(set, 0, cl->record_offset, number); client_set_state(cl, Client_Working); + connection_continue(co); return 1; } + else + { + yaz_log(YLOG_LOG, "cl=%s. OK no more in total set", client_get_id(cl)); + } return 0; }