X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fconnection.c;h=fbdaf797b19a0795677b5bb7b0acc485bea80f5f;hb=24ad8ea356d71c764af19897e2719670a94a3a05;hp=98a73e00bd7316057981bb565879e6b88f44cd23;hpb=7f0b4d88eca113e5eb0beac2046180e9ff9d08ea;p=pazpar2-moved-to-github.git diff --git a/src/connection.c b/src/connection.c index 98a73e0..fbdaf79 100644 --- a/src/connection.c +++ b/src/connection.c @@ -333,6 +333,7 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man) 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); @@ -423,12 +424,22 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man) 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