X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebrasrv.c;h=cf3a4db86ec9a143281deb136f2aacadc83500bd;hb=27a6d4f7f7425896345ab5a2bfdf35a96c97416e;hp=3283d5f16c8fbcc3e7fe96d7a275dcd23fb277a7;hpb=20d1df123f3e5be61a77687223952430ac184cd9;p=idzebra-moved-to-github.git diff --git a/index/zebrasrv.c b/index/zebrasrv.c index 3283d5f..cf3a4db 100644 --- a/index/zebrasrv.c +++ b/index/zebrasrv.c @@ -1,5 +1,5 @@ -/* $Id: zebrasrv.c,v 1.1 2006-09-22 10:18:08 adam Exp $ - Copyright (C) 1995-2006 +/* $Id: zebrasrv.c,v 1.12 2007-03-14 11:48:32 adam Exp $ + Copyright (C) 1995-2007 Index Data ApS This file is part of the Zebra server. @@ -261,6 +261,15 @@ static void search_terms(ZebraHandle zh, bend_search_rr *r) } } + +static int break_handler(void *client_data) +{ + 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; @@ -274,12 +283,15 @@ int bend_search(void *handle, bend_search_rr *r) zebra_result (zh, &r->errcode, &r->errstring); return 0; } + zebra_set_break_handler(zh, break_handler, r->association); yaz_log (YLOG_DEBUG, "ResultSet '%s'", r->setname); switch (r->query->which) { case Z_Query_type_1: case Z_Query_type_101: - res = zebra_search_RPN(zh, r->stream, r->query->u.type_1, - r->setname, &zhits); + res = zebra_search_RPN_x(zh, r->stream, r->query->u.type_1, + r->setname, &zhits, + &r->estimated_hit_count, + &r->partial_resultset); if (res != ZEBRA_OK) zebra_result(zh, &r->errcode, &r->errstring); else @@ -297,6 +309,7 @@ int bend_search(void *handle, bend_search_rr *r) default: r->errcode = YAZ_BIB1_QUERY_TYPE_UNSUPP; } + zebra_set_break_handler(zh, 0, 0); return 0; } @@ -585,8 +598,8 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) Z_External *rec = notToKeep->elements[i]->record; struct oident *oident = 0; Odr_oct *opaque_recid = 0; - SYSNO *sysno = 0; - SYSNO sysno_tmp; + zint *sysno = 0; + zint sysno_tmp; if (notToKeep->elements[i]->u.opaque) { @@ -630,7 +643,8 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) rec->u.octet_aligned->len, rec->u.octet_aligned->buf); } - if (oident && oident->value != VAL_TEXT_XML) + if (oident && oident->value != VAL_TEXT_XML + && oident->value != VAL_SUTRS) { rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED; rr->errstring = "only XML update supported"; @@ -638,102 +652,56 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) } if (rec->which == Z_External_octet) { - int action = 0; + enum zebra_recctrl_action_t action = action_update; + char recid_str[256]; + const char *match_criteria = 0; + ZEBRA_RES res; if (*toKeep->action == Z_IUOriginPartToKeep_recordInsert) - action = 1; - if (*toKeep->action == + action = action_insert; + else if (*toKeep->action == Z_IUOriginPartToKeep_recordReplace) - action = 2; - if (*toKeep->action == + action = action_replace; + else if (*toKeep->action == Z_IUOriginPartToKeep_recordDelete) - action = 3; - if (*toKeep->action == + action = action_delete; + else if (*toKeep->action == Z_IUOriginPartToKeep_specialUpdate) - action = 4; - - if (!action) + action = action_update; + else { rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED; rr->errstring = "unsupported ES Update action"; break; } - else if (opaque_recid) + + if (opaque_recid) { - int r = zebra_admin_exchange_record ( - zh, - (const char *) rec->u.octet_aligned->buf, - rec->u.octet_aligned->len, - (const char *) opaque_recid->buf, - opaque_recid->len, - action); - if (r) + size_t l = opaque_recid->len; + if (l >= sizeof(recid_str)) { - zebra_result(zh, &rr->errcode, - &rr->errstring); + rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED; + rr->errstring = "opaque record ID too large"; break; } - } - else - { - ZEBRA_RES r = ZEBRA_FAIL; - switch(action) { - case 1: - r = zebra_insert_record( - zh, - 0, /* recordType */ - sysno, - 0, /* match */ - 0, /* fname */ - (const char *) rec->u.octet_aligned->buf, - rec->u.octet_aligned->len, - 0); - if (r == ZEBRA_FAIL) - { - rr->errcode = - YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED; - rr->errstring = "insert_record failed"; - } - break; - case 2: - case 4: - r = zebra_update_record( - zh, - 0, /* recordType */ - sysno, - 0, /* match */ - 0, /* fname */ - (const char *) rec->u.octet_aligned->buf, - rec->u.octet_aligned->len, - 1); - if (r == ZEBRA_FAIL) - { - rr->errcode = - YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED; - rr->errstring = "update_record failed"; - } - break; - case 3: - r = zebra_delete_record( - zh, - 0, /* recordType */ - sysno, - 0, /* match */ - 0, /* fname */ - (const char *) rec->u.octet_aligned->buf, - rec->u.octet_aligned->len, - 0); - if (r == ZEBRA_FAIL) - { - rr->errcode = - YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED; - rr->errstring = "delete_record failed"; - } - break; - } - } + memcpy(recid_str, opaque_recid->buf, l); + recid_str[l] = '\0'; + match_criteria = recid_str; + } + res = zebra_update_record( + zh, action, + 0, /* recordType */ + sysno, match_criteria, 0, /* fname */ + (const char *) rec->u.octet_aligned->buf, + rec->u.octet_aligned->len); + if (res == ZEBRA_FAIL) + { + rr->errcode = + YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED; + rr->errstring = "update_record failed"; + } } } if (zebra_end_trans (zh) != ZEBRA_OK) @@ -756,9 +724,14 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) static void bend_start (struct statserv_options_block *sob) { + Res default_res = res_open(0, 0); + if (sob->handle) zebra_stop((ZebraService) sob->handle); - sob->handle = zebra_start(sob->configname); + res_set(default_res, "profilePath", DEFAULT_PROFILE_PATH); + res_set(default_res, "modulePath", DEFAULT_MODULE_PATH); + sob->handle = zebra_start_res(sob->configname, default_res, 0); + res_close(default_res); if (!sob->handle) { yaz_log (YLOG_FATAL, "Failed to read config `%s'", sob->configname);