return strategy_plus_sort;
}
+int client_fetch_more(struct client *cl)
+{
+ int extra = cl->hits - cl->record_offset;
+ if (extra > 0)
+ {
+ ZOOM_resultset set = cl->resultset;
+ int max_extra = 10;
+
+ if (extra > max_extra)
+ extra = max_extra;
+
+ ZOOM_resultset_records(set, 0, cl->record_offset, extra);
+ client_set_state(cl, Client_Working);
+ return 1;
+ }
+ return 0;
+}
+
int client_parse_init(struct client *cl, int same_search)
{
cl->same_search = same_search;
iochan_man_t iochan,
const struct timeval *abstime);
int client_start_search(struct client *cl);
+int client_fetch_more(struct client *cl);
int client_parse_init(struct client *cl, int same_search);
int client_parse_range(struct client *cl, const char *startrecs, const char *maxrecs);
int client_parse_sort(struct client *cl, struct reclist_sortparms *sp);
static YAZ_MUTEX g_http_session_mutex = 0;
static int g_http_sessions = 0;
+static void show_records_ready(void *data);
+
int get_version(struct http_request *rq) {
const char *version = http_argbyname(rq, "version");
int version_no = 0;
}
- rl = show_range_start(s->psession, sp, startn, &numn, &total, &total_hits, &approx_hits);
+ i = numn;
+ rl = show_range_start(s->psession, sp, startn, &numn, &total,
+ &total_hits, &approx_hits);
+ if (i > numn)
+ {
+ show_range_stop(s->psession, rl);
+ session_log(s->psession, YLOG_LOG,
+ "Subset %d < %d retrieved for show", numn, i);
+ if (!session_fetch_more(s->psession))
+ session_log(s->psession, YLOG_LOG, "can not fetch more");
+ else
+ {
+ session_log(s->psession, YLOG_LOG, "fetching more in progress");
+ if (session_set_watch(s->psession, SESSION_WATCH_SHOW,
+ show_records_ready, c, c))
+ session_log(s->psession, YLOG_WARN, "Ignoring show block");
+ else
+ {
+ session_log(s->psession, YLOG_LOG, "session watch OK");
+ return;
+ }
+ }
+ rl = show_range_start(s->psession, sp, startn, &numn, &total,
+ &total_hits, &approx_hits);
+ }
response_open(c, "show");
wrbuf_printf(c->wrbuf, "\n<activeclients>%d</activeclients>\n", active);
}
+int session_fetch_more(struct session *se)
+{
+ struct client_list *l;
+ int ret = 0;
+
+ for (l = se->clients_active; l; l = l->next)
+ {
+ struct client *cl = l->client;
+ if (client_get_state(cl) == Client_Idle)
+ {
+ if (client_fetch_more(cl))
+ {
+ session_log(se, YLOG_LOG, "%s: more to fetch",
+ client_get_id(cl));
+ ret = 1;
+ }
+ else
+ {
+ session_log(se, YLOG_LOG, "%s: no more to fetch",
+ client_get_id(cl));
+ }
+ }
+ else
+ {
+ session_log(se, YLOG_LOG, "%s: no fetch due to state=%s",
+ client_get_id(cl), client_get_state_str(cl));
+ }
+
+ }
+ return ret;
+}
+
struct record_cluster **show_range_start(struct session *se,
struct reclist_sortparms *sp,
int start, int *num, int *total,
struct record_cluster **show_range_start(struct session *s,
struct reclist_sortparms *sp,
int start,
- int *num, int *total, Odr_int *sumhits, Odr_int *approximation);
+ int *num, int *total,
+ Odr_int *sumhits,
+ Odr_int *approximation);
+
+int session_fetch_more(struct session *s);
void show_range_stop(struct session *s, struct record_cluster **recs);
struct record_cluster *show_single_start(struct session *s, const char *id,