enum client_state state;
struct show_raw *show_raw;
struct client *next; // next client in session or next in free list
+ ZOOM_resultset resultset;
};
struct show_raw {
static int nativesyntax_to_type(struct session_database *sdb, char *type,
ZOOM_record rec);
-static void client_show_immediate(struct client *cl, int position,
- void *data,
- void (*error_handler)(void *data, const char *addinfo),
- void (*record_handler)(void *data, const char *buf,
- size_t sz),
- int binary)
+static void client_show_immediate(
+ ZOOM_resultset resultset, struct session_database *sdb, int position,
+ void *data,
+ void (*error_handler)(void *data, const char *addinfo),
+ void (*record_handler)(void *data, const char *buf, size_t sz),
+ int binary)
{
- struct connection *co = cl->connection;
- struct session_database *sdb = client_get_database(cl);
- ZOOM_resultset resultset = 0;
ZOOM_record rec = 0;
char type[80];
const char *buf;
int len;
- assert(co);
-
- resultset = connection_get_resultset(co);
if (!resultset)
{
error_handler(data, "no resultset");
size_t sz),
int binary)
{
- if (!cl->connection)
- return -1;
-
if (syntax == 0 && esn == 0)
- client_show_immediate(cl, position, data,
+ client_show_immediate(cl->resultset, client_get_database(cl),
+ position, data,
error_handler, record_handler,
binary);
else
{
struct show_raw *rr, **rrp;
+
+ if (!cl->connection)
+ return -1;
+
+
rr = xmalloc(sizeof(*rr));
rr->position = position;
rr->active = 0;
if (cl->state == Client_Failed)
{
- client_show_raw_error(cl, "client failed");
+ client_show_raw_error(cl, "client failed");
}
else if (cl->state == Client_Disconnected)
{
{
struct session_database *sdb = client_get_database(cl);
struct connection *co = client_get_connection(cl);
- ZOOM_resultset set = connection_get_resultset(co);
+ ZOOM_resultset set = cl->resultset;
int offset = cl->show_raw->position;
const char *syntax = 0;
struct connection *co = cl->connection;
struct session *se = cl->session;
ZOOM_connection link = connection_get_link(co);
- ZOOM_resultset resultset = connection_get_resultset(co);
+ ZOOM_resultset resultset = cl->resultset;
const char *error, *addinfo;
if (ZOOM_connection_error(link, &error, &addinfo))
{
struct connection *co = cl->connection;
ZOOM_connection link = connection_get_link(co);
- ZOOM_resultset resultset = connection_get_resultset(co);
+ ZOOM_resultset resultset = cl->resultset;
const char *error, *addinfo;
if (ZOOM_connection_error(link, &error, &addinfo))
ZOOM_connection_option_set(link, "databaseName", databaseName);
ZOOM_connection_option_set(link, "presentChunk", "20");
-
+
if (cl->cqlquery)
{
ZOOM_query q = ZOOM_query_create();
yaz_log(YLOG_LOG, "Search %s PQF: %s", sdb->database->url, cl->pquery);
rs = ZOOM_connection_search_pqf(link, cl->pquery);
}
- connection_set_resultset(co, rs);
+ ZOOM_resultset_destroy(cl->resultset);
+ cl->resultset = rs;
connection_continue(co);
}
r->diagnostic = 0;
r->state = Client_Disconnected;
r->show_raw = 0;
+ r->resultset = 0;
r->next = 0;
return r;
}
if (c->connection)
connection_release(c->connection);
+
+ ZOOM_resultset_destroy(c->resultset);
+ c->resultset = 0;
c->next = client_freelist;
client_freelist = c;
}
struct connection {
IOCHAN iochan;
ZOOM_connection link;
- ZOOM_resultset resultset;
struct host *host;
struct client *client;
char *ibuf;
return co->link;
}
-ZOOM_resultset connection_get_resultset(struct connection *co)
-{
- return co->resultset;
-}
-
-void connection_set_resultset(struct connection *co, ZOOM_resultset rs)
-{
- if (co->resultset)
- ZOOM_resultset_destroy(co->resultset);
- co->resultset = rs;
-}
-
static void remove_connection_from_host(struct connection *con)
{
struct connection **conp = &con->host->connections;
ZOOM_connection_destroy(co->link);
iochan_destroy(co->iochan);
}
- if (co->resultset)
- ZOOM_resultset_destroy(co->resultset);
-
yaz_log(YLOG_DEBUG, "Connection destroy %s", co->host->hostport);
remove_connection_from_host(co);
new->zproxy = 0;
client_set_connection(cl, new);
new->link = 0;
- new->resultset = 0;
new->state = Conn_Resolving;
if (host->ipport)
connection_connect(new);