summaryrefslogtreecommitdiffstats
path: root/src/rspamd.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-14 12:39:56 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-14 12:39:56 +0100
commit8fd0795feffdde4dd3a9f2fbe8c6ba517be370bf (patch)
treef03452c979e1f630137d83340fbfb1a6d185c5fb /src/rspamd.c
parent1453b09a9885edc0a8aa99d728c01bc96db5bb86 (diff)
downloadrspamd-8fd0795feffdde4dd3a9f2fbe8c6ba517be370bf.tar.gz
rspamd-8fd0795feffdde4dd3a9f2fbe8c6ba517be370bf.zip
[Feature] Rework listening system to allow multiple socket types per worker
Diffstat (limited to 'src/rspamd.c')
-rw-r--r--src/rspamd.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/rspamd.c b/src/rspamd.c
index 72e676267..99fa6ca39 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -340,20 +340,38 @@ rspamd_fork_delayed (struct rspamd_worker_conf *cf,
}
static GList *
-create_listen_socket (GPtrArray *addrs, guint cnt, gint listen_type)
+create_listen_socket (GPtrArray *addrs, guint cnt,
+ enum rspamd_worker_socket_type listen_type)
{
GList *result = NULL;
gint fd;
guint i;
- gpointer p;
+ struct rspamd_worker_listen_socket *ls;
g_ptr_array_sort (addrs, rspamd_inet_address_compare_ptr);
for (i = 0; i < cnt; i ++) {
- fd = rspamd_inet_address_listen (g_ptr_array_index (addrs, i),
- listen_type, TRUE);
- if (fd != -1) {
- p = GINT_TO_POINTER (fd);
- result = g_list_prepend (result, p);
+
+ if (listen_type & RSPAMD_WORKER_SOCKET_TCP) {
+ fd = rspamd_inet_address_listen (g_ptr_array_index (addrs, i),
+ SOCK_STREAM, TRUE);
+ if (fd != -1) {
+ ls = g_slice_alloc0 (sizeof (*ls));
+ ls->addr = g_ptr_array_index (addrs, i);
+ ls->fd = fd;
+ ls->type = RSPAMD_WORKER_SOCKET_TCP;
+ result = g_list_prepend (result, ls);
+ }
+ }
+ if (listen_type & RSPAMD_WORKER_SOCKET_UDP) {
+ fd = rspamd_inet_address_listen (g_ptr_array_index (addrs, i),
+ SOCK_DGRAM, TRUE);
+ if (fd != -1) {
+ ls = g_slice_alloc0 (sizeof (*ls));
+ ls->addr = g_ptr_array_index (addrs, i);
+ ls->fd = fd;
+ ls->type = RSPAMD_WORKER_SOCKET_TCP;
+ result = g_list_prepend (result, ls);
+ }
}
}
@@ -492,7 +510,7 @@ spawn_workers (struct rspamd_main *rspamd_main, struct event_base *ev_base)
key = make_listen_key (bcf);
if ((p =
g_hash_table_lookup (listen_sockets,
- GINT_TO_POINTER (key))) == NULL) {
+ GINT_TO_POINTER (key))) == NULL) {
if (!bcf->is_systemd) {
/* Create listen socket */