X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fconnection.c;h=9ca21424841d4cea88ebd8237bcf77e189cb4e02;hb=0bb0ee0e00d750808e228b991c78cb4838bc989d;hp=b456f0d94e186e09324ead8028bc1c8d51b06e4a;hpb=8961ed761e348e972f00d015284ce75c16b1648c;p=pazpar2-moved-to-github.git diff --git a/src/connection.c b/src/connection.c index b456f0d..9ca2142 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2012 Index Data + Copyright (C) 2006-2013 Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -216,6 +216,8 @@ static void non_block_events(struct connection *co) #endif switch (ev) { + case ZOOM_EVENT_TIMEOUT: + break; case ZOOM_EVENT_END: { const char *error, *addinfo; @@ -224,7 +226,7 @@ static void non_block_events(struct connection *co) { yaz_log(YLOG_LOG, "Error %s from %s", error, client_get_id(cl)); - client_set_diagnostic(cl, err, addinfo); + client_set_diagnostic(cl, err, error, addinfo); client_set_state(cl, Client_Error); } else @@ -288,7 +290,7 @@ void connection_continue(struct connection *co) { yaz_log(YLOG_LOG, "Error %s from %s", error, client_get_id(co->client)); - client_set_diagnostic(co->client, err, addinfo); + client_set_diagnostic(co->client, err, error, addinfo); client_set_state_nb(co->client, Client_Error); } } @@ -320,22 +322,14 @@ static void connection_handler(IOCHAN iochan, int event) } else if (event & EVENT_TIMEOUT) { - if (co->state == Conn_Connecting) - { - yaz_log(YLOG_WARN, "%p connect timeout %s", co, client_get_id(cl)); + ZOOM_connection_fire_event_timeout(co->link); + client_lock(cl); + non_block_events(co); + client_unlock(cl); - client_set_state(cl, Client_Error); - remove_connection_from_host(co); - yaz_mutex_leave(host->mutex); - connection_destroy(co); - } - else - { - yaz_log(YLOG_LOG, "%p Connection idle timeout %s", co, client_get_id(cl)); - remove_connection_from_host(co); - yaz_mutex_leave(host->mutex); - connection_destroy(co); - } + remove_connection_from_host(co); + yaz_mutex_leave(host->mutex); + connection_destroy(co); } else { @@ -469,13 +463,13 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man) return -1; } - if (sru && *sru) + if (sru && *sru && !strstr(host->url, "://")) { - char http_hostport[512]; - strcpy(http_hostport, "http://"); - strcat(http_hostport, host->url); - yaz_log(YLOG_LOG, "SRU connect to : %s", http_hostport); - ZOOM_connection_connect(con->link, http_hostport, 0); + WRBUF w = wrbuf_alloc(); + wrbuf_puts(w, "http://"); + wrbuf_puts(w, host->url); + ZOOM_connection_connect(con->link, wrbuf_cstr(w), 0); + wrbuf_destroy(w); } else {