aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-09 16:35:31 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-09 16:35:31 +0100
commit0988e1b1b1d0a3a82728df658d834aba199baf4c (patch)
treec11398141f13392115000713ab44eb6b35caa646 /src/libserver
parent60ef2e36f2264d1d0baf61116324f9bcb11eadfc (diff)
downloadrspamd-0988e1b1b1d0a3a82728df658d834aba199baf4c.tar.gz
rspamd-0988e1b1b1d0a3a82728df658d834aba199baf4c.zip
[Feature] Add protection against open files limit and accepting sockets
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/worker_util.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index d3e296d6d..b50b0384f 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -248,7 +248,7 @@ rspamd_prepare_worker (struct rspamd_worker *worker, const char *name,
void (*accept_handler)(int, short, void *))
{
struct event_base *ev_base;
- struct event *accept_event;
+ struct event *accept_events;
GList *cur;
struct rspamd_worker_listen_socket *ls;
@@ -276,13 +276,13 @@ rspamd_prepare_worker (struct rspamd_worker *worker, const char *name,
ls = cur->data;
if (ls->fd != -1) {
- accept_event = g_slice_alloc0 (sizeof (struct event));
- event_set (accept_event, ls->fd, EV_READ | EV_PERSIST,
+ accept_events = g_slice_alloc0 (sizeof (struct event) * 2);
+ event_set (&accept_events[0], ls->fd, EV_READ | EV_PERSIST,
accept_handler, worker);
- event_base_set (ev_base, accept_event);
- event_add (accept_event, NULL);
+ event_base_set (ev_base, &accept_events[0]);
+ event_add (&accept_events[0], NULL);
worker->accept_events = g_list_prepend (worker->accept_events,
- accept_event);
+ accept_events);
}
cur = g_list_next (cur);
@@ -296,7 +296,7 @@ void
rspamd_worker_stop_accept (struct rspamd_worker *worker)
{
GList *cur;
- struct event *event;
+ struct event *events;
GHashTableIter it;
struct rspamd_worker_signal_handler *sigh;
gpointer k, v;
@@ -305,10 +305,11 @@ rspamd_worker_stop_accept (struct rspamd_worker *worker)
/* Remove all events */
cur = worker->accept_events;
while (cur) {
- event = cur->data;
- event_del (event);
+ events = cur->data;
+ event_del (&events[0]);
+ event_del (&events[1]);
cur = g_list_next (cur);
- g_slice_free1 (sizeof (struct event), event);
+ g_slice_free1 (sizeof (struct event) * 2, events);
}
if (worker->accept_events != NULL) {