X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-c.c;h=5c62a07585f91225ea9a74aced4171cc5cec85dd;hp=53cbb10306b29edd5bfbd5729daac26b1b4ba3c6;hb=a6b61b9f8b6576e8159a4e7e6aee88bba7e5d07d;hpb=d84e4c3cd444d04aee7beeadb5bb0ae061ee24c9 diff --git a/src/zoom-c.c b/src/zoom-c.c index 53cbb10..5c62a07 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -49,7 +49,6 @@ static void initlog(void) } } -void ZOOM_connection_remove_tasks(ZOOM_connection c); static zoom_ret send_HTTP_redirect(ZOOM_connection c, const char *uri); void ZOOM_set_dset_error(ZOOM_connection c, int error, @@ -84,7 +83,6 @@ void ZOOM_set_dset_error(ZOOM_connection c, int error, c, c->host_port ? c->host_port : "<>", dset, error, addinfo ? addinfo : "", addinfo2 ? addinfo2 : ""); - ZOOM_connection_remove_tasks(c); } } @@ -1559,11 +1557,23 @@ static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres) char *addinfo = 0; const char *connection_head = z_HTTP_header_lookup(hres->headers, "Connection"); + int must_close = 0; const char *location; ZOOM_connection_set_mask(c, 0); yaz_log(c->log_details, "%p handle_http", c); - + if (!strcmp(hres->version, "1.0")) + { + /* HTTP 1.0: only if Keep-Alive we stay alive.. */ + if (!connection_head || strcmp(connection_head, "Keep-Alive")) + must_close = 1; + } + else + { + /* HTTP 1.1: only if no close we stay alive.. */ + if (connection_head && !strcmp(connection_head, "close")) + must_close = 1; + } yaz_cookies_response(c->cookies, hres); if ((hres->code == 301 || hres->code == 302) && c->sru_mode == zoom_sru_get && (location = z_HTTP_header_lookup(hres->headers, "Location"))) @@ -1616,33 +1626,18 @@ static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres) yaz_log(c->log_details, "removing tasks in handle_http"); ZOOM_connection_remove_task(c); } + if (must_close) { - int must_close = 0; - if (!strcmp(hres->version, "1.0")) - { - /* HTTP 1.0: only if Keep-Alive we stay alive.. */ - if (!connection_head || strcmp(connection_head, "Keep-Alive")) - must_close = 1; - } - else + ZOOM_connection_close(c); + if (c->tasks) { - /* HTTP 1.1: only if no close we stay alive.. */ - if (connection_head && !strcmp(connection_head, "close")) - must_close = 1; + c->tasks->running = 0; + ZOOM_connection_insert_task(c, ZOOM_TASK_CONNECT); + c->reconnect_ok = 0; } - if (must_close) - { - ZOOM_connection_close(c); - if (c->tasks) - { - c->tasks->running = 0; - ZOOM_connection_insert_task(c, ZOOM_TASK_CONNECT); - c->reconnect_ok = 0; - } - } - else - c->reconnect_ok = 1; /* if the server closes anyway */ } + else + c->reconnect_ok = 1; /* if the server closes anyway */ } #endif @@ -2009,7 +2004,8 @@ static void ZOOM_connection_do_io(ZOOM_connection c, int mask) else ZOOM_connection_exec_task(c); } - c->state = STATE_ESTABLISHED; + if (c->cs && cs_look(c->cs) == CS_DATA) + c->state = STATE_ESTABLISHED; } else {