diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-03-13 17:30:06 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-03-13 17:30:06 +0400 |
commit | c2418c4890493f350198d1d990427e601fa2bf6e (patch) | |
tree | 2e20da62b3bbdd068c25fb329e68bd173f968cd4 /src/main.c | |
parent | db1f276aa8d6ed66340919fe1c7fa454c52fea43 (diff) | |
download | rspamd-c2418c4890493f350198d1d990427e601fa2bf6e.tar.gz rspamd-c2418c4890493f350198d1d990427e601fa2bf6e.zip |
Fix proxy logic.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/src/main.c b/src/main.c index caced2b17..a342a56ea 100644 --- a/src/main.c +++ b/src/main.c @@ -553,38 +553,43 @@ spawn_workers (struct rspamd_main *rspamd) while (cur) { cf = cur->data; - if (cf->worker->has_socket) { - if ((p = g_hash_table_lookup (listen_sockets, GINT_TO_POINTER ( - make_listen_key (&cf->bind_addr, cf->bind_port, cf->bind_family, cf->bind_host)))) == NULL) { - /* Create listen socket */ - listen_sock = create_listen_socket (&cf->bind_addr, cf->bind_port, cf->bind_family, cf->bind_host); - if (listen_sock == -1) { - exit (-errno); + if (cf->worker == NULL) { + msg_err ("type of worker is unspecified, skip spawning"); + } + else { + if (cf->worker->has_socket) { + if ((p = g_hash_table_lookup (listen_sockets, GINT_TO_POINTER ( + make_listen_key (&cf->bind_addr, cf->bind_port, cf->bind_family, cf->bind_host)))) == NULL) { + /* Create listen socket */ + listen_sock = create_listen_socket (&cf->bind_addr, cf->bind_port, cf->bind_family, cf->bind_host); + if (listen_sock == -1) { + exit (-errno); + } + g_hash_table_insert (listen_sockets, GINT_TO_POINTER ( + make_listen_key (&cf->bind_addr, cf->bind_port, cf->bind_family, cf->bind_host)), + GINT_TO_POINTER (listen_sock)); } - g_hash_table_insert (listen_sockets, GINT_TO_POINTER ( - make_listen_key (&cf->bind_addr, cf->bind_port, cf->bind_family, cf->bind_host)), - GINT_TO_POINTER (listen_sock)); - } - else { - /* We had socket for this type of worker */ - listen_sock = GPOINTER_TO_INT (p); + else { + /* We had socket for this type of worker */ + listen_sock = GPOINTER_TO_INT (p); + } + cf->listen_sock = listen_sock; } - cf->listen_sock = listen_sock; - } - - if (cf->worker->unique) { - if (cf->count > 1) { - msg_err ("cannot spawn more than 1 %s worker, so spawn one", cf->worker->name); + + if (cf->worker->unique) { + if (cf->count > 1) { + msg_err ("cannot spawn more than 1 %s worker, so spawn one", cf->worker->name); + } + fork_worker (rspamd, cf); } - fork_worker (rspamd, cf); - } - else if (cf->worker->threaded) { - fork_worker (rspamd, cf); - } - else { - for (i = 0; i < cf->count; i++) { + else if (cf->worker->threaded) { fork_worker (rspamd, cf); } + else { + for (i = 0; i < cf->count; i++) { + fork_worker (rspamd, cf); + } + } } cur = g_list_next (cur); |