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)
{
}
}
-
-// 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;
#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