From: Adam Dickmeiss Date: Thu, 30 Oct 2014 11:57:38 +0000 (+0100) Subject: Merge branch 'master' into paz-927 X-Git-Tag: v1.12.0~14 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=1c46d5e50ea73b0c0dc00bf745921ab2236b3a80;p=pazpar2-moved-to-github.git Merge branch 'master' into paz-927 Conflicts: src/client.c src/connection.c src/connection.h --- 1c46d5e50ea73b0c0dc00bf745921ab2236b3a80 diff --cc src/client.c index e5a2e5d,60553fd..275bd40 --- a/src/client.c +++ b/src/client.c @@@ -1165,12 -1164,26 +1164,32 @@@ void client_disconnect(struct client *c client_set_connection(cl, 0); } +void client_mark_dead(struct client *cl) +{ + if (cl->connection) + connection_mark_dead(cl->connection); +} + + void client_stop(struct client *cl) + { + client_lock(cl); + if (cl->state == Client_Working || cl->state == Client_Connecting) + { + yaz_log(YLOG_LOG, "client_stop: %s release", client_get_id(cl)); + if (cl->connection) + { + connection_release2(cl->connection); + assert(cl->ref_count > 1); + cl->ref_count--; + cl->connection = 0; + } + cl->state = Client_Disconnected; + } + else + yaz_log(YLOG_LOG, "client_stop: %s ignore", client_get_id(cl)); + client_unlock(cl); + } + // Initialize CCL map for a target static CCL_bibset prepare_cclmap(struct client *cl, CCL_bibset base_bibset) { diff --cc src/connection.c index 2c7c0c2,c52fcf3..7483118 --- a/src/connection.c +++ b/src/connection.c @@@ -318,8 -348,76 +318,13 @@@ static void connection_handler(IOCHAN i } } - -// Disassociate connection from client -static void connection_release(struct connection *co) -{ - struct client *cl = co->client; - - if (!cl) - return; - client_set_connection(cl, 0); - co->client = 0; -} - + void connection_release2(struct connection *co) + { + co->client = 0; + } + -void connect_resolver_host(struct host *host, iochan_man_t iochan_man) -{ - struct connection *con; - - yaz_mutex_enter(host->mutex); - con = host->connections; - while (con) - { - if (con->state == Conn_Closed) - { - struct client *cl = con->client; - if (!host->ipport || !cl) /* unresolved or no client */ - { - remove_connection_from_host(con); - yaz_mutex_leave(host->mutex); - connection_destroy(con); - } - else - { - struct session_database *sdb = client_get_database(cl); - struct session *se = client_get_session(cl); - if (sdb && se) - { - yaz_mutex_leave(host->mutex); - client_start_search(cl); - } - else - { - remove_connection_from_host(con); - yaz_mutex_leave(host->mutex); - connection_destroy(con); - } - } - /* start all over .. at some point it will be NULL */ - yaz_mutex_enter(host->mutex); - con = host->connections; - } - else - { - con = con->next; - } - } - yaz_mutex_leave(host->mutex); -} - -static struct host *connection_get_host(struct connection *con) -{ - return con->host; -} - static int connection_connect(struct connection *con, iochan_man_t iochan_man) { - struct host *host = connection_get_host(con); ZOOM_options zoptions = ZOOM_options_create(); const char *auth; const char *charset; diff --cc src/connection.h index fe4f83a,1b7b24c..459127e --- a/src/connection.h +++ b/src/connection.h @@@ -28,10 -28,13 +28,11 @@@ Foundation, Inc., 51 Franklin St, Fift #include "eventl.h" struct connection; -struct host; -void connect_resolver_host(struct host *host, iochan_man_t iochan); ZOOM_connection connection_get_link(struct connection *co); void connection_continue(struct connection *co); -void connect_resolver_host(struct host *host, iochan_man_t iochan_man); +void connection_mark_dead(struct connection *co); + void connection_release2(struct connection *co); #endif