diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-01-16 20:59:37 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-01-16 20:59:37 +0400 |
commit | 9bacf0d835d66aaddcdb9e664a34364f25ed2554 (patch) | |
tree | 8aa7287724a3abce1b6b63dc7215e101d44eb87d /src/util.c | |
parent | 9f2cb66ccbce8cd0fb659b79063bcebf1d816a1d (diff) | |
download | rspamd-9bacf0d835d66aaddcdb9e664a34364f25ed2554.tar.gz rspamd-9bacf0d835d66aaddcdb9e664a34364f25ed2554.zip |
* Introduce new system of worker's and modules initialization:
- Removed legacy limitation of worker's types;
- Using GQuarks to identify workers and modules;
- Remove modules.sh script;
- Add a common system of workers and modules;
- Write management and configuration for new architecture.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 74 |
1 files changed, 23 insertions, 51 deletions
diff --git a/src/util.c b/src/util.c index 23203255b..5fcf0858b 100644 --- a/src/util.c +++ b/src/util.c @@ -1161,57 +1161,6 @@ rspamd_strlcpy (gchar *dst, const gchar *src, gsize siz) return (s - src - 1); /* count does not include NUL */ } -/* Convert process type to its name */ -const gchar * -process_to_str (enum process_type type) -{ - switch (type) { - case TYPE_MAIN: - return "main"; - case TYPE_WORKER: - return "worker"; - case TYPE_FUZZY: - return "fuzzy"; - case TYPE_CONTROLLER: - return "controller"; - case TYPE_LMTP: - return "lmtp"; - case TYPE_SMTP: - return "smtp"; - case TYPE_KVSTORAGE: - return "keystorage"; - default: - return "unknown"; - } - - return NULL; -} -/* Convert string to process type */ -enum process_type -str_to_process (const gchar *str) -{ - if (g_ascii_strcasecmp (str, "main") == 0) { - return TYPE_MAIN; - } - else if (g_ascii_strcasecmp (str, "worker") == 0) { - return TYPE_WORKER; - } - else if (g_ascii_strcasecmp (str, "fuzzy") == 0) { - return TYPE_FUZZY; - } - else if (g_ascii_strcasecmp (str, "controller") == 0) { - return TYPE_CONTROLLER; - } - else if (g_ascii_strcasecmp (str, "smtp") == 0) { - return TYPE_SMTP; - } - else if (g_ascii_strcasecmp (str, "lmtp") == 0) { - return TYPE_LMTP; - } - - return TYPE_UNKNOWN; -} - /* Compare two emails for building emails tree */ gint compare_email_func (gconstpointer a, gconstpointer b) @@ -1396,6 +1345,29 @@ rspamd_fallocate (gint fd, off_t offset, off_t len) #endif } + +/** + * Return worker's control structure by its type + * @param type + * @return worker's control structure or NULL + */ +worker_t* +get_worker_by_type (GQuark type) +{ + worker_t **cur; + + cur = &workers[0]; + while (*cur) { + if (g_quark_from_string ((*cur)->name) == type) { + return *cur; + } + cur ++; + } + + return NULL; +} + + /* * vi:ts=4 */ |