From: Adam Dickmeiss Date: Mon, 19 Aug 2002 21:09:10 +0000 (+0000) Subject: timeout option for ZOOM X-Git-Tag: YAZ.1.8.9~2 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=87efa99fe797d07045266a5e0d876ac8b0e28a34;p=yaz-moved-to-github.git timeout option for ZOOM --- diff --git a/retrieval/d1_marc.c b/retrieval/d1_marc.c index e649b58..bb2ea47 100644 --- a/retrieval/d1_marc.c +++ b/retrieval/d1_marc.c @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: d1_marc.c,v 1.22 2002-08-17 07:56:59 adam Exp $ + * $Id: d1_marc.c,v 1.23 2002-08-19 21:09:10 adam Exp $ */ @@ -228,11 +228,15 @@ static int nodetomarc(data1_handle dh, } if (selected && !field->u.tag.node_selected) continue; + + subf = field->child; + if (!subf) + continue; + len += 4 + p->length_data_entry + p->length_starting + p->length_implementation; base_address += 3 + p->length_data_entry + p->length_starting + p->length_implementation; - subf = field->child; if (subf->which == DATA1N_data) is00X = 1; @@ -289,6 +293,8 @@ static int nodetomarc(data1_handle dh, continue; subf = field->child; + if (!subf) + continue; if (subf->which == DATA1N_data) is00X = 1; diff --git a/retrieval/d1_read.c b/retrieval/d1_read.c index 539c915..7f3c4a3 100644 --- a/retrieval/d1_read.c +++ b/retrieval/d1_read.c @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: d1_read.c,v 1.47 2002-07-29 20:04:08 adam Exp $ + * $Id: d1_read.c,v 1.48 2002-08-19 21:09:10 adam Exp $ */ #include @@ -39,9 +39,19 @@ data1_node *data1_get_root_tag (data1_handle dh, data1_node *n) */ data1_node *get_parent_tag (data1_handle dh, data1_node *n) { - for (; n && n->which != DATA1N_root; n = n->parent) - if (n->which == DATA1N_tag) - return n; + if (data1_is_xmlmode(dh)) + { + for (; n && n->which != DATA1N_root; n = n->parent) + if (n->which == DATA1N_tag && n->parent && + n->parent->which != DATA1N_root) + return n; + } + else + { + for (; n && n->which != DATA1N_root; n = n->parent) + if (n->which == DATA1N_tag) + return n; + } return 0; } @@ -185,16 +195,24 @@ data1_node *data1_mk_tag_n (data1_handle dh, NMEM nmem, { data1_node *partag = get_parent_tag(dh, at); data1_node *res = data1_mk_node2 (dh, nmem, DATA1N_tag, at); - data1_element *e = NULL; data1_xattr **p; + data1_element *e = 0; res->u.tag.tag = data1_insert_string_n (dh, res, nmem, tag, len); - if (partag) - e = partag->u.tag.element; - res->u.tag.element = - data1_getelementbytagname (dh, at->root->u.root.absyn, - e, res->u.tag.tag); + if (!partag) /* top tag? */ + e = data1_getelementbytagname (dh, at->root->u.root.absyn, + 0 /* index as local */, + res->u.tag.tag); + else + { + /* only set element for known tags */ + e = partag->u.tag.element; + if (e) + e = data1_getelementbytagname (dh, at->root->u.root.absyn, + e, res->u.tag.tag); + } + res->u.tag.element = e; p = &res->u.tag.attributes; while (attr && *attr) { @@ -338,9 +356,14 @@ static data1_node *data1_add_insert_taggeddata(data1_handle dh, data1_node *datn = 0; data1_node *tagn = 0; - if (partag) + if (!partag) + e = data1_getelementbytagname (dh, root->u.root.absyn, 0, tagname); + else + { e = partag->u.tag.element; - e = data1_getelementbytagname (dh, root->u.root.absyn, e, tagname); + if (e) + e = data1_getelementbytagname (dh, root->u.root.absyn, e, tagname); + } if (local_allowed || e) { tagn = data1_mk_node2 (dh, m, DATA1N_tag, at); @@ -884,7 +907,8 @@ static void data1_iconv_s (data1_handle dh, NMEM m, data1_node *n, data1_xattr *p; for (p = n->u.tag.attributes; p; p = p->next) { - if (conv_item(m, t, wrbuf, p->value, strlen(p->value)) + if (p->value && + conv_item(m, t, wrbuf, p->value, strlen(p->value)) == 0) { wrbuf_puts (wrbuf, ""); diff --git a/zoom/zoom-c.c b/zoom/zoom-c.c index 3fbd46b..2ea510a 100644 --- a/zoom/zoom-c.c +++ b/zoom/zoom-c.c @@ -1,5 +1,5 @@ /* - * $Id: zoom-c.c,v 1.38 2002-07-29 19:51:34 adam Exp $ + * $Id: zoom-c.c,v 1.39 2002-08-19 21:09:10 adam Exp $ * * ZOOM layer for C, connections, result sets, queries. */ @@ -2302,6 +2302,7 @@ ZOOM_connection_last_event(ZOOM_connection cs) ZOOM_API(int) ZOOM_event (int no, ZOOM_connection *cs) { + int timeout = 5000; #if HAVE_SYS_POLL_H struct pollfd pollfds[1024]; ZOOM_connection poll_cs[1024]; @@ -2338,18 +2339,17 @@ ZOOM_event (int no, ZOOM_connection *cs) #if HAVE_SYS_POLL_H #else - tv.tv_sec = 25; - tv.tv_usec = 0; - FD_ZERO (&input); FD_ZERO (&output); FD_ZERO (&except); #endif + yaz_log (LOG_LOG, "select begin"); nfds = 0; for (i = 0; ioptions, "timeout", -1); + if (this_timeout != -1 && this_timeout < timeout) + timeout = this_timeout; + yaz_log (LOG_LOG, "time_timeout = %d, p=%p, timeout=%d", this_timeout, + c, timeout); #if HAVE_SYS_POLL_H if (mask) { @@ -2396,10 +2401,15 @@ ZOOM_event (int no, ZOOM_connection *cs) } #endif } + if (timeout >= 5000) + timeout = 30; + if (!nfds) return 0; + yaz_log (LOG_LOG, "select with timeout %d", timeout); + #if HAVE_SYS_POLL_H - r = poll (pollfds, nfds, 25000); + r = poll (pollfds, nfds, timeout * 1000); for (i = 0; i