X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-c.c;h=53cbb10306b29edd5bfbd5729daac26b1b4ba3c6;hp=f97123d489c79dc8a5214038296770e9257d01e2;hb=d84e4c3cd444d04aee7beeadb5bb0ae061ee24c9;hpb=45fb4747b80f37bfa44738e1071c094f18660ae9 diff --git a/src/zoom-c.c b/src/zoom-c.c index f97123d..53cbb10 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -266,6 +266,7 @@ ZOOM_API(ZOOM_connection) c->host_port = 0; c->proxy = 0; c->tproxy = 0; + c->proxy_mode = 0; c->charset = c->lang = 0; @@ -1078,8 +1079,11 @@ static zoom_ret do_connect_host(ZOOM_connection c, const char *logical_url) if (c->cs) cs_close(c->cs); - c->cs = cs_create_host_proxy(logical_url, CS_FLAGS_DNS_NO_BLOCK, &add, - c->tproxy ? c->tproxy : c->proxy); + c->cs = cs_create_host2(logical_url, CS_FLAGS_DNS_NO_BLOCK, &add, + c->tproxy ? c->tproxy : c->proxy, + &c->proxy_mode); + if (!c->proxy) + c->proxy_mode = 0; if (c->cs && c->cs->protocol == PROTO_HTTP) { @@ -1675,22 +1679,26 @@ static int do_read(ZOOM_connection c) if (!z_GDU(c->odr_in, &gdu, 0, 0)) { - int x; - int err = odr_geterrorx(c->odr_in, &x); - char msg[100]; - const char *element = odr_getelement(c->odr_in); - yaz_snprintf(msg, sizeof(msg), - "ODR code %d:%d element=%s offset=%d", - err, x, element ? element : "", - odr_offset(c->odr_in)); - ZOOM_set_error(c, ZOOM_ERROR_DECODE, msg); - if (c->log_api) + /* even on failures we try to re-connect (HTTP) */ + if (!ZOOM_test_reconnect(c)) { - FILE *ber_file = yaz_log_file(); - if (ber_file) - odr_dumpBER(ber_file, c->buf_in, r); + int x; + int err = odr_geterrorx(c->odr_in, &x); + char msg[100]; + const char *element = odr_getelement(c->odr_in); + yaz_snprintf(msg, sizeof(msg), + "ODR code %d:%d element=%s offset=%d", + err, x, element ? element : "", + odr_offset(c->odr_in)); + ZOOM_set_error(c, ZOOM_ERROR_DECODE, msg); + if (c->log_api) + { + FILE *ber_file = yaz_log_file(); + if (ber_file) + odr_dumpBER(ber_file, c->buf_in, r); + } + ZOOM_connection_close(c); } - ZOOM_connection_close(c); } else {