X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fseshigh.c;h=92627c26a0e5c9fd716f5bc7748ef255446f4e7b;hp=0a3f9fac901a31ad170235f0634348b17772ab7c;hb=2715f6522ca62ab5dbc886c21ed18945743216f0;hpb=c1250b6b91fc106645f28bff1d6188936434a494 diff --git a/src/seshigh.c b/src/seshigh.c index 0a3f9fa..92627c2 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -33,7 +33,6 @@ #include #include #include -#include #if HAVE_SYS_TYPES_H #include @@ -57,7 +56,6 @@ #include #endif -#include #include #include #include "eventl.h" @@ -300,7 +298,9 @@ int ir_read(IOCHAN h, int event) else if (res <= 0) { yaz_log(log_session, "Connection closed by client"); - assoc->state = ASSOC_DEAD; + cs_close(conn); + destroy_association(assoc); + iochan_destroy(h); return 0; } else if (res == 1) /* incomplete read - wait for more */ @@ -540,6 +540,9 @@ static int srw_bend_init(association *assoc, Z_SRW_diagnostic **d, int *num, Z_S len = strlen(sr->username) + 1; if (sr->password) len += strlen(sr->password) + 2; + yaz_log(log_requestdetail, "username=%s password-len=%ld", + sr->username, (long) + (sr->password ? strlen(sr->password) : 0)); auth->which = Z_IdAuthentication_open; auth->u.open = (char *) odr_malloc(assoc->decode, len); strcpy(auth->u.open, sr->username); @@ -754,7 +757,7 @@ static int srw_bend_fetch(association *assoc, int pos, } static int cql2pqf(ODR odr, const char *cql, cql_transform_t ct, - Z_Query *query_result) + Z_Query *query_result, char **sortkeys_p) { /* have a CQL query and CQL to PQF transform .. */ CQL_parser cp = cql_parser_create(); @@ -762,7 +765,8 @@ static int cql2pqf(ODR odr, const char *cql, cql_transform_t ct, int srw_errcode = 0; const char *add = 0; char rpn_buf[5120]; - + + *sortkeys_p = 0; r = cql_parser_string(cp, cql); if (r) { @@ -770,12 +774,29 @@ static int cql2pqf(ODR odr, const char *cql, cql_transform_t ct, } if (!r) { + struct cql_node *cn = cql_parser_result(cp); + /* Syntax OK */ - r = cql_transform_buf(ct, - cql_parser_result(cp), - rpn_buf, sizeof(rpn_buf)-1); + r = cql_transform_buf(ct, cn, rpn_buf, sizeof(rpn_buf)-1); if (r) srw_errcode = cql_transform_error(ct, &add); + else + { + char out[100]; + int r = cql_sortby_to_sortkeys_buf(cn, out, sizeof(out)-1); + + if (r == 0) + { + if (*out) + yaz_log(log_requestdetail, "srw_sortKeys '%s'", out); + *sortkeys_p = odr_strdup(odr, out); + } + else + { + yaz_log(log_requestdetail, "failed to create srw_sortKeys"); + srw_errcode = YAZ_SRW_UNSUPP_SORT_TYPE; + } + } } if (!r) { @@ -808,7 +829,8 @@ static int cql2pqf_scan(ODR odr, const char *cql, cql_transform_t ct, { Z_Query query; Z_RPNQuery *rpn; - int srw_error = cql2pqf(odr, cql, ct, &query); + char *sortkeys = 0; + int srw_error = cql2pqf(odr, cql, ct, &query, &sortkeys); if (srw_error) return srw_error; if (query.which != Z_Query_type_1 && query.which != Z_Query_type_101) @@ -882,7 +904,9 @@ static void srw_bend_search(association *assoc, { int srw_errcode = cql2pqf(assoc->encode, srw_req->query.cql, assoc->server->cql_transform, - rr.query); + rr.query, + &rr.srw_sortKeys); + if (srw_errcode) { yaz_add_srw_diagnostic(assoc->encode, @@ -941,9 +965,9 @@ static void srw_bend_search(association *assoc, rr.stream = assoc->encode; rr.decode = assoc->decode; rr.print = assoc->print; - if ( srw_req->sort.sortKeys ) + if (srw_req->sort.sortKeys) rr.srw_sortKeys = odr_strdup(assoc->encode, - srw_req->sort.sortKeys ); + srw_req->sort.sortKeys); rr.association = assoc; rr.hits = 0; rr.errcode = 0; @@ -1857,7 +1881,6 @@ static void process_http_request(association *assoc, request *req) {0, 0, 0} }; char ctype[80]; - int ret; p = z_get_HTTP_Response(o, 200); hres = p->u.HTTP_Response; @@ -1868,9 +1891,9 @@ static void process_http_request(association *assoc, request *req) if (stylesheet && *stylesheet == '\0') stylesheet = 0; - ret = z_soap_codec_enc_xsl(assoc->encode, &soap_package, - &hres->content_buf, &hres->content_len, - soap_handlers, charset, stylesheet); + z_soap_codec_enc_xsl(assoc->encode, &soap_package, + &hres->content_buf, &hres->content_len, + soap_handlers, charset, stylesheet); hres->code = http_code; strcpy(ctype, "text/xml"); @@ -1917,7 +1940,7 @@ static void process_http_request(association *assoc, request *req) int t; const char *alive = z_HTTP_header_lookup(hreq->headers, "Keep-Alive"); - if (alive && isdigit(*(const unsigned char *) alive)) + if (alive && yaz_isdigit(*(const unsigned char *) alive)) t = atoi(alive); else t = 15; @@ -2593,7 +2616,7 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb) bsrr->extra_args = 0; bsrr->extra_response_data = 0; - yaz_log (log_requestdetail, "ResultSet '%s'", req->resultSetName); + yaz_log(log_requestdetail, "ResultSet '%s'", req->resultSetName); if (req->databaseNames) { int i; @@ -2627,7 +2650,8 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb) /* have a CQL query and a CQL to PQF transform .. */ int srw_errcode = cql2pqf(bsrr->stream, req->query->u.type_104->u.cql, - assoc->server->cql_transform, bsrr->query); + assoc->server->cql_transform, bsrr->query, + &bsrr->srw_sortKeys); if (srw_errcode) bsrr->errcode = yaz_diag_srw_to_bib1(srw_errcode); } @@ -2837,7 +2861,6 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb) Odr_int *next; Odr_int *num; int errcode = 0; - const char *errstring = 0; yaz_log(log_requestdetail, "Got PresentRequest."); @@ -2866,7 +2889,6 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb) resp->records = diagrec(assoc, bprr->errcode, bprr->errstring); *resp->presentStatus = Z_PresentStatus_failure; errcode = bprr->errcode; - errstring = bprr->errstring; } } apdu = (Z_APDU *)odr_malloc(assoc->encode, sizeof(*apdu)); @@ -2945,6 +2967,7 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb) if (req->stepSize) step_size = odr_int_to_int(*req->stepSize); + res->stepSize = 0; res->scanStatus = scanStatus; res->numberOfEntriesReturned = numberOfEntriesReturned; res->positionOfTerm = 0;