iochan_man_t iochan_man)
{
struct connection *co;
+ int ret;
co = xmalloc(sizeof(*co));
co->operation_timeout = operation_timeout;
co->session_timeout = session_timeout;
- connection_connect(co, iochan_man);
-
+ ret = connection_connect(co, iochan_man);
connection_use(1);
+ if (ret)
+ { /* error */
+ connection_destroy(co);
+ co = 0;
+ }
return co;
}
{
struct client *cl = co->client;
if (cl)
- {
- client_check_preferred_watch(cl);
client_got_records(cl);
- }
}
}
const char *sru;
const char *sru_version = 0;
const char *value;
+ int r = 0;
WRBUF w;
struct session_database *sdb = client_get_database(con->client);
con->state = Conn_Connecting;
iochan_settimeout(con->iochan, con->operation_timeout);
iochan_setdata(con->iochan, con);
- iochan_add(iochan_man, con->iochan);
-
- client_set_state(con->client, Client_Connecting);
+ if (iochan_add(iochan_man, con->iochan))
+ {
+ yaz_log(YLOG_FATAL, "Out of connections");
+ iochan_destroy(con->iochan);
+ con->iochan = 0;
+ ZOOM_connection_destroy(con->link);
+ con->link = 0;
+ r = -1;
+ }
+ else
+ {
+ client_set_state(con->client, Client_Connecting);
+ }
ZOOM_options_destroy(zoptions);
wrbuf_destroy(w);
- return 0;
+ return r;
}
// Ensure that client has a connection associated
client_get_id(cl), url);
co = client_get_connection(cl);
+ if (co)
+ return 2;
if (!co)
{
co = connection_create(cl, url, zproxy,