int r = 0;
WRBUF w;
- struct session_database *sdb = client_get_database(con->client);
+ struct client *cl = con->client;
+ struct session_database *sdb = client_get_database(cl);
const char *apdulog = session_setting_oneval(sdb, PZ_APDULOG);
+ struct session *se = client_get_session(cl);
const char *memcached = session_setting_oneval(sdb, PZ_MEMCACHED);
const char *redis = session_setting_oneval(sdb, PZ_REDIS);
if (!(con->link = ZOOM_connection_create(zoptions)))
{
- yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create ZOOM Connection");
+ session_log(se, YLOG_WARN, "%s: ZOOM_connection_create failed",
+ client_get_id(cl));
ZOOM_options_destroy(zoptions);
return -1;
}
con->state = Conn_Connecting;
iochan_settimeout(con->iochan, con->operation_timeout);
iochan_setdata(con->iochan, con);
- if (iochan_add(iochan_man, con->iochan))
+ if (iochan_add(iochan_man, con->iochan, 20))
{
- yaz_log(YLOG_FATAL, "Out of connections");
+ session_log(se, YLOG_WARN, "%s: out of connections", client_get_id(cl));
iochan_destroy(con->iochan);
con->iochan = 0;
ZOOM_connection_destroy(con->link);
}
else
{
- client_set_state(con->client, Client_Connecting);
+ client_set_state(cl, Client_Connecting);
}
ZOOM_options_destroy(zoptions);
wrbuf_destroy(w);
#endif
if (max_sockets)
man->limit_fd = max_sockets;
- yaz_log(YLOG_LOG, "iochan max threads %d max sockets %d",
- no_threads, max_sockets);
+ yaz_log(YLOG_LOG, "iochan threads %d limit fd %d", no_threads,
+ man->limit_fd);
yaz_mutex_create(&man->iochan_mutex);
return man;
}
}
}
-int iochan_add(iochan_man_t man, IOCHAN chan)
+int iochan_add(iochan_man_t man, IOCHAN chan, int slack)
{
int r = 0, no_fds = 0;
IOCHAN p;
if (p->fd >= 0)
no_fds++;
}
- if (chan->fd > 0 && man->limit_fd > 0 && no_fds >= man->limit_fd)
+ if (slack >= 0 && man->limit_fd > 0 && no_fds >= man->limit_fd - slack)
{
r = -1;
yaz_log(YLOG_WARN, "max channels %d in use", no_fds);
iochan_man_t iochan_man_create(int no_threads, int max_sockets);
-int iochan_add(iochan_man_t man, IOCHAN chan);
+int iochan_add(iochan_man_t man, IOCHAN chan, int slack);
void iochan_man_events(iochan_man_t man);
void iochan_man_destroy(iochan_man_t *mp);
void iochan_destroy(IOCHAN chan);
p->iochan = iochan_create(sock, proxy_io, EVENT_INPUT, "http_proxy");
iochan_setdata(p->iochan, p);
- if (iochan_add(ser->iochan_man, p->iochan))
+ if (iochan_add(ser->iochan_man, p->iochan, 5))
{
iochan_destroy(p->iochan);
xfree(p);
ch = http_channel_create(server->http_server, host, server);
ch->iochan = c;
iochan_setdata(c, ch);
- if (iochan_add(server->iochan_man, c))
+ if (iochan_add(server->iochan_man, c, 0))
{
+ yaz_log(YLOG_WARN, "Refusing incoming HTTP connection");
http_channel_destroy(c);
}
}
}
c = iochan_create(s, http_accept, EVENT_INPUT|EVENT_EXCEPT, "http_server");
- if (iochan_add(server->iochan_man, c))
+ if (iochan_add(server->iochan_man, c, 0))
{
+ yaz_log(YLOG_WARN, "Can not create HTTP binding socket");
iochan_destroy(c);
return -1;
}
r->timeout_iochan, service->session_timeout);
iochan_settimeout(r->timeout_iochan, service->session_timeout);
- iochan_add(service->server->iochan_man, r->timeout_iochan);
+ iochan_add(service->server->iochan_man, r->timeout_iochan, -1);
http_session_use(1);
return r;
}
YAZ_CHECK(p);
if (p)
{
- iochan_man_t chan_man = iochan_man_create(10);
+ iochan_man_t chan_man = iochan_man_create(10, 0);
IOCHAN chan = iochan_create(thread_fd, iochan_handler,
EVENT_INPUT|EVENT_TIMEOUT, "test_chan");
iochan_settimeout(chan, 1);
iochan_setdata(chan, p);
- iochan_add(chan_man, chan);
+ iochan_add(chan_man, chan, -1);
iochan_man_events(chan_man);
sel_thread_destroy(p);