int present_chunk = 20; // Default chunk size
int rc_prep_connection;
+ cl->diagnostic = 0;
+ cl->record_failures = cl->ingest_failures = cl->filtered = 0;
yaz_gettimeofday(&tval);
tval.tv_sec += 5;
session_log(se, YLOG_LOG, "%s: new search", client_get_id(cl));
- cl->diagnostic = 0;
- cl->record_failures = cl->ingest_failures = cl->filtered = 0;
-
client_destroy_xdoc(cl);
client_init_xdoc(cl);
client_set_connection(cl, 0);
}
+void client_stop(struct client *cl)
+{
+ client_lock(cl);
+ if (cl->state == Client_Working || cl->state == Client_Connecting)
+ {
+ yaz_log(YLOG_LOG, "client_stop: %s release", client_get_id(cl));
+ if (cl->connection)
+ {
+ connection_release2(cl->connection);
+ assert(cl->ref_count > 1);
+ cl->ref_count--;
+ cl->connection = 0;
+ }
+ cl->state = Client_Disconnected;
+ }
+ else
+ yaz_log(YLOG_LOG, "client_stop: %s ignore", client_get_id(cl));
+ client_unlock(cl);
+}
+
// Initialize CCL map for a target
static CCL_bibset prepare_cclmap(struct client *cl, CCL_bibset base_bibset)
{
void client_got_records(struct client *c);
void client_lock(struct client *c);
void client_unlock(struct client *c);
+void client_stop(struct client *c);
int client_has_facet(struct client *cl, const char *name);
void client_check_preferred_watch(struct client *cl);
co->client = 0;
}
+void connection_release2(struct connection *co)
+{
+ co->client = 0;
+}
+
void connect_resolver_host(struct host *host, iochan_man_t iochan_man)
{
struct connection *con;
ZOOM_connection connection_get_link(struct connection *co);
void connection_continue(struct connection *co);
void connect_resolver_host(struct host *host, iochan_man_t iochan_man);
+void connection_release2(struct connection *co);
#endif
release_session(c, s);
}
+static void cmd_stop(struct http_channel *c)
+{
+ struct http_session *s = locate_session(c);
+ if (!s)
+ return;
+ response_open_ok(c, "stop");
+ session_stop(s->psession);
+ response_close(c, "stop");
+ release_session(c, s);
+}
+
static void cmd_info(struct http_channel *c)
{
char yaz_version_str[20];
{ "ping", cmd_ping },
{ "record", cmd_record },
{ "info", cmd_info },
+ { "stop", cmd_stop },
{0,0}
};
}
}
+void session_stop(struct session *se)
+{
+ struct client_list *l;
+ session_enter(se, "session_stop1");
+ if (se->clients_starting)
+ {
+ session_leave(se, "session_stop1");
+ return;
+ }
+ se->clients_starting = 1;
+ session_leave(se, "session_stop1");
+
+ session_alert_watch(se, SESSION_WATCH_SHOW);
+ session_alert_watch(se, SESSION_WATCH_BYTARGET);
+ session_alert_watch(se, SESSION_WATCH_TERMLIST);
+ session_alert_watch(se, SESSION_WATCH_SHOW_PREF);
+
+ for (l = se->clients_active; l; l = l->next)
+ {
+ struct client *cl = l->client;
+ client_stop(cl);
+ }
+ session_enter(se, "session_stop2");
+ se->clients_starting = 0;
+ session_leave(se, "session_stop2");
+}
+
enum pazpar2_error_code session_search(struct session *se,
const char *query,
const char *startrecs,
void session_apply_setting(struct session *se, const char *dbname,
const char *setting, const char *value);
const char *session_setting_oneval(struct session_database *db, int offset);
+void session_stop(struct session *se);
int ingest_record(struct client *cl, const char *rec, int record_no, NMEM nmem);
int ingest_xml_record(struct client *cl, xmlDoc *xdoc,