diff options
-rw-r--r-- | CMakeLists.txt | 38 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 210 | ||||
-rw-r--r-- | lib/client/librspamdclient.c | 34 | ||||
-rw-r--r-- | src/cdb/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/client/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/json/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/lua/CMakeLists.txt | 11 | ||||
-rw-r--r-- | src/util.c | 21 | ||||
-rw-r--r-- | src/util.h | 2 | ||||
-rw-r--r-- | src/worker.c | 21 |
10 files changed, 208 insertions, 147 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3afda7769..c1530e468 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,6 +310,19 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") SET(CMAKE_INSTALL_RPATH "${PREFIX}/lib") ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") +# Set libdir +IF(NOT LIBDIR) + SET(LIBDIR lib/rspamd) + IF(NOT CMAKE_INSTALL_RPATH) + SET(CMAKE_INSTALL_RPATH ${PREFIX}/${LIBDIR}) + ENDIF(NOT CMAKE_INSTALL_RPATH) +ENDIF(NOT LIBDIR) + +# Set includedir +IF(NOT INCLUDEDIR) + SET(INCLUDEDIR include/rspamd) +ENDIF(NOT INCLUDEDIR) + # Check prefixes IF(NOT ETC_PREFIX) IF(CMAKE_INSTALL_PREFIX) @@ -932,17 +945,15 @@ SET_TARGET_PROPERTIES(rspamd PROPERTIES LINKER_LANGUAGE C) SET_TARGET_PROPERTIES(rspamd PROPERTIES COMPILE_FLAGS "-DRSPAMD_MAIN") SET_TARGET_PROPERTIES(rspamd PROPERTIES VERSION ${RSPAMD_VERSION}) -TARGET_LINK_LIBRARIES(rspamd rspamdserver) +TARGET_LINK_LIBRARIES(rspamd rspamd-mime) +TARGET_LINK_LIBRARIES(rspamd rspamd-server) +TARGET_LINK_LIBRARIES(rspamd rspamd-util) +TARGET_LINK_LIBRARIES(rspamd rspamd-lua) IF(LIBJUDY_LIBRARY) TARGET_LINK_LIBRARIES(rspamd Judy) ENDIF(LIBJUDY_LIBRARY) -IF(LIBDB_LIBRARY) - TARGET_LINK_LIBRARIES(rspamd db) -ENDIF(LIBDB_LIBRARY) -IF(SQLITE_LIBRARIES) - TARGET_LINK_LIBRARIES(rspamd ${SQLITE_LIBRARIES}) -ENDIF(SQLITE_LIBRARIES) + TARGET_LINK_LIBRARIES(rspamd event) IF(HAVE_LIBEVENT2) TARGET_LINK_LIBRARIES(rspamd event_pthreads) @@ -950,22 +961,11 @@ ENDIF(HAVE_LIBEVENT2) TARGET_LINK_LIBRARIES(rspamd ${PCRE_LIBRARIES}) TARGET_LINK_LIBRARIES(rspamd ${CMAKE_REQUIRED_LIBRARIES}) -TARGET_LINK_LIBRARIES(rspamd ${GLIB2_LIBRARIES}) -IF(GMIME24) - TARGET_LINK_LIBRARIES(rspamd ${GMIME24_LIBRARIES}) -ELSE(GMIME24) - TARGET_LINK_LIBRARIES(rspamd ${GMIME2_LIBRARIES}) -ENDIF(GMIME24) -IF(OPENSSL_FOUND) - TARGET_LINK_LIBRARIES(rspamd ${OPENSSL_LIBRARIES}) -ENDIF(OPENSSL_FOUND) IF(ENABLE_STATIC MATCHES "ON") TARGET_LINK_LIBRARIES(rspamd ${PCRE_LIBRARIES}) ENDIF(ENABLE_STATIC MATCHES "ON") -TARGET_LINK_LIBRARIES(rspamd hiredis) - IF(ENABLE_LUAJIT MATCHES "ON") TARGET_LINK_LIBRARIES(rspamd "${LUAJIT_LIBRARY}") ELSE(ENABLE_LUAJIT MATCHES "ON") @@ -975,7 +975,7 @@ ENDIF(ENABLE_LUAJIT MATCHES "ON") IF(ENABLE_GPERF_TOOLS MATCHES "ON") TARGET_LINK_LIBRARIES(rspamd profiler) ENDIF(ENABLE_GPERF_TOOLS MATCHES "ON") - +TARGET_LINK_LIBRARIES(rspamd hiredis) IF(GLIB_COMPAT) TARGET_LINK_LIBRARIES(rspamd glibadditions) ENDIF(GLIB_COMPAT) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a0350e012..2ef90dec2 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,105 +1,170 @@ # Librspamdclient -SET(LIBRSPAMDSRC client/librspamdclient.c - ../src/mem_pool.c - ../src/upstream.c - ../src/printf.c) +SET(LIBRSPAMDCLIENTSRC client/librspamdclient.c ) + +# Librspamd-util +SET(LIBRSPAMDUTILSRC ../src/aio_event.c + ../src/bloom.c + ../src/diff.c + ../src/fstring.c + ../src/fuzzy.c + ../src/hash.c + ../src/memcached.c + ../src/mem_pool.c + ../src/printf.c + ../src/radix.c + ../src/trie.c + ../src/upstream.c + ../src/util.c) + +# kvstorageclient + +SET(LIBRKVSTORAGESRC kvstorage/libkvstorageclient.c) -ADD_LIBRARY(rspamdclient SHARED ${LIBRSPAMDSRC}) -ADD_LIBRARY(rspamdclient_static STATIC ${LIBRSPAMDSRC}) -SET_TARGET_PROPERTIES(rspamdclient PROPERTIES PUBLIC_HEADER "client/librspamdclient.h") - -IF(CMAKE_COMPILER_IS_GNUCC) -SET_TARGET_PROPERTIES(rspamdclient PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing") -SET_TARGET_PROPERTIES(rspamdclient_static PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing") -ENDIF(CMAKE_COMPILER_IS_GNUCC) - -TARGET_LINK_LIBRARIES(rspamdclient ${CMAKE_REQUIRED_LIBRARIES}) -TARGET_LINK_LIBRARIES(rspamdclient pcre) -TARGET_LINK_LIBRARIES(rspamdclient ${GLIB2_LIBRARIES}) - -TARGET_LINK_LIBRARIES(rspamdclient_static ${CMAKE_REQUIRED_LIBRARIES}) -TARGET_LINK_LIBRARIES(rspamdclient_static ${GLIB2_LIBRARIES}) - -SET_TARGET_PROPERTIES(rspamdclient PROPERTIES VERSION ${RSPAMD_VERSION}) -SET_TARGET_PROPERTIES(rspamdclient_static PROPERTIES VERSION ${RSPAMD_VERSION}) - -IF(GLIB_COMPAT) - INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/contrib/lgpl") - TARGET_LINK_LIBRARIES(rspamdclient glibadditions) -ENDIF(GLIB_COMPAT) - -INSTALL(TARGETS rspamdclient rspamdclient_static LIBRARY PUBLIC_HEADER - LIBRARY DESTINATION lib - PUBLIC_HEADER DESTINATION include - ARCHIVE DESTINATION lib) - - # Librspamdserver -SET(RSPAMDLIBSRC - ../src/aio_event.c +SET(LIBRSPAMDSERVERSRC ../src/binlog.c - ../src/bloom.c ../src/buffer.c ../src/cfg_utils.c ../src/cfg_xml.c - ../src/diff.c ../src/dkim.c ../src/dns.c ../src/events.c - ../src/expressions.c - ../src/filter.c - ../src/fstring.c - ../src/fuzzy.c - ../src/hash.c ../src/html.c - ../src/images.c ../src/kvstorage.c ../src/kvstorage_config.c ../src/kvstorage_file.c ../src/lmtp_proto.c ../src/logger.c ../src/map.c - ../src/memcached.c - ../src/mem_pool.c - ../src/message.c - ../src/printf.c - ../src/protocol.c ../src/proxy.c - ../src/radix.c ../src/settings.c ../src/spf.c ../src/smtp_proto.c - ../src/smtp_utils.c ../src/statfile.c ../src/statfile_sync.c ../src/symbols_cache.c - ../src/trie.c - ../src/upstream.c ../src/url.c - ../src/util.c ../src/view.c) + +# Librspamd mime +SET(LIBRSPAMDMIMESRC + ../src/expressions.c + ../src/filter.c + ../src/images.c + ../src/message.c + ../src/protocol.c + ../src/smtp_utils.c) +# Add targets + +# Rspamdutil +ADD_LIBRARY(rspamd-util SHARED ${LIBRSPAMDUTILSRC}) +IF(CMAKE_COMPILER_IS_GNUCC) +SET_TARGET_PROPERTIES(rspamd-util PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing") +ENDIF(CMAKE_COMPILER_IS_GNUCC) + +TARGET_LINK_LIBRARIES(rspamd-util ${CMAKE_REQUIRED_LIBRARIES}) +TARGET_LINK_LIBRARIES(rspamd-util pcre) +TARGET_LINK_LIBRARIES(rspamd-util ${GLIB2_LIBRARIES}) +TARGET_LINK_LIBRARIES(rspamd-util event) + +SET_TARGET_PROPERTIES(rspamd-util PROPERTIES VERSION ${RSPAMD_VERSION}) + +IF(GLIB_COMPAT) + INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/contrib/lgpl") + TARGET_LINK_LIBRARIES(rspamd-util glibadditions) +ENDIF(GLIB_COMPAT) + +INSTALL(TARGETS rspamd-util + LIBRARY DESTINATION ${LIBDIR} + PUBLIC_HEADER DESTINATION include + ARCHIVE DESTINATION ${LIBDIR}) + +# Rspamd client +ADD_LIBRARY(rspamdclient SHARED ${LIBRSPAMDCLIENTSRC}) +ADD_LIBRARY(rspamdclient_static STATIC ${LIBRSPAMDCLIENTSRC}) +SET_TARGET_PROPERTIES(rspamdclient PROPERTIES PUBLIC_HEADER "client/librspamdclient.h") + +IF(CMAKE_COMPILER_IS_GNUCC) +SET_TARGET_PROPERTIES(rspamdclient PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing") +SET_TARGET_PROPERTIES(rspamdclient_static PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing") +ENDIF(CMAKE_COMPILER_IS_GNUCC) + +TARGET_LINK_LIBRARIES(rspamdclient rspamd-util) + +TARGET_LINK_LIBRARIES(rspamdclient_static ${CMAKE_REQUIRED_LIBRARIES}) +TARGET_LINK_LIBRARIES(rspamdclient_static ${GLIB2_LIBRARIES}) + +SET_TARGET_PROPERTIES(rspamdclient PROPERTIES VERSION ${RSPAMD_VERSION}) +SET_TARGET_PROPERTIES(rspamdclient_static PROPERTIES VERSION ${RSPAMD_VERSION}) + +IF(GLIB_COMPAT) + INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/contrib/lgpl") + TARGET_LINK_LIBRARIES(rspamdclient glibadditions) +ENDIF(GLIB_COMPAT) + +INSTALL(TARGETS rspamdclient rspamdclient_static LIBRARY PUBLIC_HEADER + LIBRARY DESTINATION ${LIBDIR} + PUBLIC_HEADER DESTINATION ${INCLUDEDIR} + ARCHIVE DESTINATION ${LIBDIR}) + + +# Librspamd-server IF(WITH_DB) - LIST(APPEND RSPAMDLIBSRC ../src/kvstorage_bdb.c) + LIST(APPEND LIBRSPAMDSERVERSRC ../src/kvstorage_bdb.c) ENDIF(WITH_DB) IF(WITH_SQLITE) - LIST(APPEND RSPAMDLIBSRC ../src/kvstorage_sqlite.c) + LIST(APPEND LIBRSPAMDSERVERSRC ../src/kvstorage_sqlite.c) ENDIF(WITH_SQLITE) -ADD_LIBRARY(rspamdserver STATIC ${RSPAMDLIBSRC}) -SET_TARGET_PROPERTIES(rspamdserver PROPERTIES LINKER_LANGUAGE C) -SET_TARGET_PROPERTIES(rspamdserver PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB") -TARGET_LINK_LIBRARIES(rspamdserver rspamd_lua) -TARGET_LINK_LIBRARIES(rspamdserver rspamd_json) -TARGET_LINK_LIBRARIES(rspamdserver rspamd_cdb) +ADD_LIBRARY(rspamd-server SHARED ${LIBRSPAMDSERVERSRC}) +SET_TARGET_PROPERTIES(rspamd-server PROPERTIES LINKER_LANGUAGE C) +SET_TARGET_PROPERTIES(rspamd-server PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB") +TARGET_LINK_LIBRARIES(rspamd-server rspamd-lua) +TARGET_LINK_LIBRARIES(rspamd-server rspamd-json) +TARGET_LINK_LIBRARIES(rspamd-server rspamd-cdb) +TARGET_LINK_LIBRARIES(rspamd-server rspamd-util) +IF(CMAKE_COMPILER_IS_GNUCC) +SET_TARGET_PROPERTIES(rspamd-server PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing") +ENDIF(CMAKE_COMPILER_IS_GNUCC) +IF(WITH_DB) + TARGET_LINK_LIBRARIES(rspamd-server db) +ENDIF(WITH_DB) +IF(SQLITE_LIBRARIES) + TARGET_LINK_LIBRARIES(rspamd-server ${SQLITE_LIBRARIES}) +ENDIF(SQLITE_LIBRARIES) + +IF(OPENSSL_FOUND) + TARGET_LINK_LIBRARIES(rspamd-server ${OPENSSL_LIBRARIES}) +ENDIF(OPENSSL_FOUND) +INSTALL(TARGETS rspamd-server + LIBRARY DESTINATION ${LIBDIR} + PUBLIC_HEADER DESTINATION ${INCLUDEDIR} + ARCHIVE DESTINATION ${LIBDIR}) + +# Librspamdmime +ADD_LIBRARY(rspamd-mime SHARED ${LIBRSPAMDMIMESRC}) +SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES LINKER_LANGUAGE C) +SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB") +TARGET_LINK_LIBRARIES(rspamd-mime rspamd-server) +TARGET_LINK_LIBRARIES(rspamd-mime rspamd-util) +IF(CMAKE_COMPILER_IS_GNUCC) +SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing") +ENDIF(CMAKE_COMPILER_IS_GNUCC) + +IF(GMIME24) + TARGET_LINK_LIBRARIES(rspamd-mime ${GMIME24_LIBRARIES}) +ELSE(GMIME24) + TARGET_LINK_LIBRARIES(rspamd-mime ${GMIME2_LIBRARIES}) +ENDIF(GMIME24) + +INSTALL(TARGETS rspamd-mime + LIBRARY DESTINATION ${LIBDIR} + PUBLIC_HEADER DESTINATION ${INCLUDEDIR} + ARCHIVE DESTINATION ${LIBDIR}) # Libkvstorageclient -SET(LIBRKVSTORAGESRC kvstorage/libkvstorageclient.c - ../src/mem_pool.c - ../src/upstream.c - ../src/printf.c - ../src/util.c) ADD_LIBRARY(kvstorageclient SHARED ${LIBRKVSTORAGESRC}) ADD_LIBRARY(kvstorageclient_static STATIC ${LIBRKVSTORAGESRC}) @@ -110,10 +175,7 @@ SET_TARGET_PROPERTIES(kvstorageclient PROPERTIES COMPILE_FLAGS "-fno-strict-alia SET_TARGET_PROPERTIES(kvstorageclient_static PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing") ENDIF(CMAKE_COMPILER_IS_GNUCC) -TARGET_LINK_LIBRARIES(kvstorageclient ${CMAKE_REQUIRED_LIBRARIES}) -TARGET_LINK_LIBRARIES(kvstorageclient pcre) -TARGET_LINK_LIBRARIES(kvstorageclient ${GLIB2_LIBRARIES}) -TARGET_LINK_LIBRARIES(kvstorageclient event) +TARGET_LINK_LIBRARIES(kvstorageclient rspamd-util) TARGET_LINK_LIBRARIES(kvstorageclient_static ${CMAKE_REQUIRED_LIBRARIES}) TARGET_LINK_LIBRARIES(kvstorageclient_static ${GLIB2_LIBRARIES}) @@ -128,6 +190,6 @@ ENDIF(GLIB_COMPAT) INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/src") INSTALL(TARGETS rspamdclient rspamdclient_static LIBRARY PUBLIC_HEADER - LIBRARY DESTINATION lib - PUBLIC_HEADER DESTINATION include - ARCHIVE DESTINATION lib) + LIBRARY DESTINATION ${LIBDIR} + PUBLIC_HEADER DESTINATION ${INCLUDEDIR} + ARCHIVE DESTINATION ${LIBDIR}) diff --git a/lib/client/librspamdclient.c b/lib/client/librspamdclient.c index dac49b5ae..2fbc2692d 100644 --- a/lib/client/librspamdclient.c +++ b/lib/client/librspamdclient.c @@ -1125,31 +1125,19 @@ rspamd_send_controller_command (struct rspamd_connection *c, const gchar *line, if ((r = read (c->socket, tmpbuf, sizeof (tmpbuf) - 1)) > 0) { /* Check the end of the buffer for END marker */ tmpbuf[r] = '\0'; - if (r >= (gint)sizeof (end_marker) - 1 && - (p = strstr (tmpbuf, end_marker)) != NULL) { - *p = '\0'; - /* Copy the rest to the result string */ - if (res == NULL) { - res = g_string_new (tmpbuf); - return res; - } - else { - /* Append data to string */ - if (r > 0) { - res = g_string_append (res, tmpbuf); - } - return res; - } + /* Store data inside res */ + if (res == NULL) { + res = g_string_new_len (tmpbuf, r); } else { - /* Store data inside res */ - if (res == NULL) { - res = g_string_new_len (tmpbuf, r); - } - else { - /* Append data to string */ - res = g_string_append_len (res, tmpbuf, r); - } + /* Append data to string */ + res = g_string_append_len (res, tmpbuf, r); + } + /* Check for END marker */ + if (res->len > sizeof (end_marker) - 1 && (p = strstr (res->str, end_marker)) != NULL) { + *p = '\0'; + res->len = p - res->str; + return res; } } } while (r > 0); diff --git a/src/cdb/CMakeLists.txt b/src/cdb/CMakeLists.txt index d0b56bc6c..ab7b8b57a 100644 --- a/src/cdb/CMakeLists.txt +++ b/src/cdb/CMakeLists.txt @@ -3,5 +3,9 @@ SET(CDBSRC cdb_init.c cdb_find.c cdb_make.c) -ADD_LIBRARY(rspamd_cdb STATIC ${CDBSRC}) -SET_TARGET_PROPERTIES(rspamd_cdb PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
\ No newline at end of file +ADD_LIBRARY(rspamd-cdb SHARED ${CDBSRC}) +SET_TARGET_PROPERTIES(rspamd-cdb PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB") +INSTALL(TARGETS rspamd-cdb + LIBRARY DESTINATION ${LIBDIR} + PUBLIC_HEADER DESTINATION ${INCLUDEDIR} + ARCHIVE DESTINATION ${LIBDIR})
\ No newline at end of file diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index a486f24d2..fe02d5e1b 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -3,7 +3,7 @@ SET(RSPAMCSRC rspamc.c) ADD_EXECUTABLE(rspamc ${RSPAMCSRC}) SET_TARGET_PROPERTIES(rspamc PROPERTIES COMPILE_FLAGS "-I${CMAKE_SOURCE_DIR}/lib") -TARGET_LINK_LIBRARIES(rspamc rspamdserver) +TARGET_LINK_LIBRARIES(rspamc rspamd-util) IF(ENABLE_STATIC MATCHES "ON") TARGET_LINK_LIBRARIES(rspamc rspamdclient_static) ELSE(ENABLE_STATIC MATCHES "ON") diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index 1f61d55a3..ad8059269 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -6,5 +6,9 @@ SET(JSONSRC dump.c utf.c value.c) -ADD_LIBRARY(rspamd_json STATIC ${JSONSRC}) -SET_TARGET_PROPERTIES(rspamd_json PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB") +ADD_LIBRARY(rspamd-json SHARED ${JSONSRC}) +SET_TARGET_PROPERTIES(rspamd-json PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB") +INSTALL(TARGETS rspamd-json + LIBRARY DESTINATION ${LIBDIR} + PUBLIC_HEADER DESTINATION ${INCLUDEDIR} + ARCHIVE DESTINATION ${LIBDIR}) diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt index e46b5c885..bdba01c27 100644 --- a/src/lua/CMakeLists.txt +++ b/src/lua/CMakeLists.txt @@ -12,7 +12,10 @@ SET(LUASRC lua_common.c lua_redis.c lua_upstream.c) -ADD_LIBRARY(rspamd_lua STATIC ${LUASRC}) -TARGET_LINK_LIBRARIES(rspamd_lua ${LUALIB}) -TARGET_LINK_LIBRARIES(rspamd_lua hiredis) -SET_TARGET_PROPERTIES(rspamd_lua PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB") +ADD_LIBRARY(rspamd-lua SHARED ${LUASRC}) +TARGET_LINK_LIBRARIES(rspamd-lua ${LUALIB}) +SET_TARGET_PROPERTIES(rspamd-lua PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB") +INSTALL(TARGETS rspamd-lua + LIBRARY DESTINATION ${LIBDIR} + PUBLIC_HEADER DESTINATION ${INCLUDEDIR} + ARCHIVE DESTINATION ${LIBDIR}) diff --git a/src/util.c b/src/util.c index 4db04c3d5..d569e9be7 100644 --- a/src/util.c +++ b/src/util.c @@ -1347,27 +1347,6 @@ rspamd_fallocate (gint fd, off_t offset, off_t len) /** - * 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; -} - -/** * Create new mutex * @return mutex or NULL */ diff --git a/src/util.h b/src/util.h index 8db8cc878..0d9834a76 100644 --- a/src/util.h +++ b/src/util.h @@ -225,7 +225,7 @@ gint rspamd_fallocate (gint fd, off_t offset, off_t len); * @param type * @return worker's control structure or NULL */ -worker_t* get_worker_by_type (GQuark type); +extern worker_t* get_worker_by_type (GQuark type); /** * Utils for working with threads to be compatible with all glib versions diff --git a/src/worker.c b/src/worker.c index 250bf7d31..1da4458d7 100644 --- a/src/worker.c +++ b/src/worker.c @@ -251,6 +251,27 @@ construct_task (struct rspamd_worker *worker) return new_task; } +/** + * 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; +} + /* * Free all structures of worker_task |