Merge branch 'master' into paz-927
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 30 Oct 2014 11:57:38 +0000 (12:57 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 30 Oct 2014 11:57:38 +0000 (12:57 +0100)
Conflicts:
src/client.c
src/connection.c
src/connection.h

1  2 
src/client.c
src/client.h
src/connection.c
src/connection.h
src/session.c
win/makefile

diff --cc 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/client.h
Simple merge
@@@ -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;
@@@ -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
  
diff --cc src/session.c
Simple merge
diff --cc win/makefile
Simple merge