So that we re-issue it when host has been resolved.
return 0;
}
-void client_start_search(struct client *cl, const char *sort_strategy_and_spec,
- int increasing)
+static const char *get_strategy_plus_sort(struct client *l, const char *field)
+{
+ struct session_database *sdb = client_get_database(l);
+ struct setting *s;
+
+ const char *strategy_plus_sort = 0;
+
+ for (s = sdb->settings[PZ_SORTMAP]; s; s = s->next)
+ {
+ char *p = strchr(s->name + 3, ':');
+ if (!p)
+ {
+ yaz_log(YLOG_WARN, "Malformed sortmap name: %s", s->name);
+ continue;
+ }
+ p++;
+ if (!strcmp(p, field))
+ {
+ strategy_plus_sort = s->value;
+ break;
+ }
+ }
+ return strategy_plus_sort;
+}
+
+void client_start_search(struct client *cl)
{
struct session_database *sdb = client_get_database(cl);
struct connection *co = client_get_connection(cl);
ZOOM_connection link = connection_get_link(co);
+ struct session *se = client_get_session(cl);
ZOOM_resultset rs;
const char *opt_piggyback = session_setting_oneval(sdb, PZ_PIGGYBACK);
const char *opt_queryenc = session_setting_oneval(sdb, PZ_QUERYENCODING);
ZOOM_query_prefix(q, cl->pquery);
}
- if (sort_strategy_and_spec &&
- strlen(sort_strategy_and_spec) < 40 /* spec below */)
- {
- char spec[50], *p;
- strcpy(spec, sort_strategy_and_spec);
- p = strchr(spec, ':');
- if (p)
+ if (se->sorted_results)
+ { /* first entry is current sorting ! */
+ const char *sort_strategy_and_spec =
+ get_strategy_plus_sort(cl, se->sorted_results->field);
+ int increasing = se->sorted_results->increasing;
+ if (sort_strategy_and_spec && strlen(sort_strategy_and_spec) < 40)
{
- *p++ = '\0'; /* cut the string in two */
- while (*p == ' ')
- p++;
- if (increasing)
- strcat(p, " <");
- else
- strcat(p, " >");
- yaz_log(YLOG_LOG, "applying %s %s", spec, p);
- ZOOM_query_sortby2(q, spec, p);
+ char spec[50], *p;
+ strcpy(spec, sort_strategy_and_spec);
+ p = strchr(spec, ':');
+ if (p)
+ {
+ *p++ = '\0'; /* cut the string in two */
+ while (*p == ' ')
+ p++;
+ if (increasing)
+ strcat(p, " <");
+ else
+ strcat(p, " >");
+ yaz_log(YLOG_LOG, "applying %s %s", spec, p);
+ ZOOM_query_sortby2(q, spec, p);
+ }
+ }
+ else
+ {
+ /* no native sorting.. If this is not the first search, then
+ skip it entirely */
+ if (se->sorted_results->next)
+ {
+ ZOOM_query_destroy(q);
+ client_set_state_nb(cl, Client_Idle);
+ return;
+ }
}
}
rs = ZOOM_connection_search(link, q);
int operation_timeout, int session_timeout,
iochan_man_t iochan,
const struct timeval *abstime);
-void client_start_search(struct client *cl, const char *sort_strategy_and_spec,
- int increasing);
+void client_start_search(struct client *cl);
void client_set_session(struct client *cl, struct session *se);
int client_is_active(struct client *cl);
int client_is_active_preferred(struct client *cl);
{
yaz_mutex_leave(host->mutex);
connection_connect(con, iochan_man);
- client_start_search(con->client, 0, 0); /* TODO */
+ client_start_search(con->client);
goto start;
}
}
struct client_list *next;
};
-struct session_sorted_results {
- const char *field;
- int increasing;
- struct session_sorted_results *next;
-};
-
/* session counting (1) , disable client counting (0) */
static YAZ_MUTEX g_session_mutex = 0;
static int no_sessions = 0;
return res == 0;
}
-static const char *get_strategy_plus_sort(struct client *l, const char *field)
-{
- struct session_database *sdb = client_get_database(l);
- struct setting *s;
-
- const char *strategy_plus_sort = 0;
-
- for (s = sdb->settings[PZ_SORTMAP]; s; s = s->next)
- {
- char *p = strchr(s->name + 3, ':');
- if (!p)
- {
- yaz_log(YLOG_WARN, "Malformed sortmap name: %s", s->name);
- continue;
- }
- p++;
- if (!strcmp(p, field))
- {
- strategy_plus_sort = s->value;
- break;
- }
- }
- return strategy_plus_sort;
-}
-
void session_sort(struct session *se, const char *field, int increasing)
{
struct session_sorted_results *sr;
for (l = se->clients; l; l = l->next)
{
struct client *cl = l->client;
- const char *strategy_plus_sort = get_strategy_plus_sort(cl, field);
- if (strategy_plus_sort)
- {
- struct timeval tval;
- 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, strategy_plus_sort, increasing);
- }
+ struct timeval tval;
+ 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);
}
session_leave(se);
}
for (l = se->clients; l; l = l->next)
{
struct client *cl = l->client;
- const char *strategy_plus_sort = get_strategy_plus_sort(cl, sort_field);
if (maxrecs)
client_set_maxrecs(cl, atoi(maxrecs));
se->service->z3950_session_timeout,
se->service->server->iochan_man,
&tval))
- client_start_search(cl, strategy_plus_sort, increasing);
+ client_start_search(cl);
}
}
facet_limits_destroy(facet_limits);
;
#endif
+struct session_sorted_results {
+ const char *field;
+ int increasing;
+ struct session_sorted_results *next;
+};
+
/*
* Local variables:
* c-basic-offset: 4