-/* $Id: api.h,v 1.43 2007-01-16 15:01:15 adam Exp $
+/* $Id: api.h,v 1.44 2007-01-17 13:22:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
YAZ_EXPORT
ZEBRA_RES zebra_set_limit(ZebraHandle zh, int complement_flag, zint *ids);
+YAZ_EXPORT
+ZEBRA_RES zebra_set_busy_handler(ZebraHandle zh,
+ int (*f)(void *client_data, ZebraHandle zh),
+ void *client_data);
+
YAZ_END_CDECL
/** \mainpage Zebra
-/* $Id: index.h,v 1.192 2007-01-16 15:31:23 adam Exp $
+/* $Id: index.h,v 1.193 2007-01-17 13:22:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
NMEM nmem_error;
struct zebra_limit *m_limit;
+
+ int (*busy_handler_func)(void *client_data);
+ void *busy_handler_data;
};
-/* $Id: zebraapi.c,v 1.244 2007-01-16 15:31:23 adam Exp $
+/* $Id: zebraapi.c,v 1.245 2007-01-17 13:22:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
zh->m_staticrank = 0;
zh->m_segment_indexing = 0;
+ zh->busy_handler_func = 0;
+ zh->busy_handler_data = 0;
+
default_encoding = res_get_def(zh->session_res, "encoding", "ISO-8859-1");
zh->iconv_to_utf8 =
zh->partial_result = 1;
}
+
+ZEBRA_RES zebra_set_busy_handler(ZebraHandle zh,
+ int (*f)(void *client_data, ZebraHandle zh),
+ void *client_data)
+{
+ zh->busy_handler_func = f;
+ zh->busy_handler_data = client_data;
+ return ZEBRA_OK;
+}
+
ZEBRA_RES zebra_search_RPN_x(ZebraHandle zh, ODR o, Z_RPNQuery *query,
const char *setname, zint *hits,
int *estimated_hit_count,
-/* $Id: zebrasrv.c,v 1.6 2007-01-16 15:01:15 adam Exp $
+/* $Id: zebrasrv.c,v 1.7 2007-01-17 13:22:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
}
}
+
+static int busy_handler(void *client_data, ZebraHandle zh)
+{
+ bend_association assoc =(bend_association) client_data;
+ if (!bend_assoc_is_alive(assoc))
+ return 1;
+ return 0;
+}
+
int bend_search(void *handle, bend_search_rr *r)
{
ZebraHandle zh = (ZebraHandle) handle;
zebra_result (zh, &r->errcode, &r->errstring);
return 0;
}
+ zebra_set_busy_handler(zh, busy_handler, r->association);
yaz_log (YLOG_DEBUG, "ResultSet '%s'", r->setname);
switch (r->query->which)
{
default:
r->errcode = YAZ_BIB1_QUERY_TYPE_UNSUPP;
}
+ zebra_set_busy_handler(zh, 0, 0);
return 0;
}
-/* $Id: zsets.c,v 1.117 2007-01-16 15:31:23 adam Exp $
+/* $Id: zsets.c,v 1.118 2007-01-17 13:22:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
key_logdump_txt(log_level_searchhits, &key, termid->name);
if (this_sys != psysno)
{ /* new record .. */
+ if (zh->busy_handler_func)
+ {
+ if (zh->busy_handler_func(zh->busy_handler_data))
+ {
+ yaz_log(YLOG_LOG, "Session end. Stop search");
+ zebraSet->estimated_hit_count = 1;
+ break;
+ }
+ }
if (rfd->counted_items > rset->hits_limit)
{
zebraSet->estimated_hit_count = 1;