diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-08 13:43:13 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-08 16:35:42 +0100 |
commit | 47e27ce0f8ecf8dff0f9abc0e0fb466a64fdc736 (patch) | |
tree | 5b1f5cbb74b0accc910985c373b9dc4fb41d7c1f /src/lua/lua_task.c | |
parent | f98bb456ab710bc3fa99cdbe5383f39c00dcd480 (diff) | |
download | rspamd-47e27ce0f8ecf8dff0f9abc0e0fb466a64fdc736.tar.gz rspamd-47e27ce0f8ecf8dff0f9abc0e0fb466a64fdc736.zip |
[Feature] Add mmap support to lua_text
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r-- | src/lua/lua_task.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 4706d69a0..a3354acb6 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -25,6 +25,7 @@ #include "email_addr.h" #include "utlist.h" #include "cryptobox.h" +#include "unix-std.h" /*** * @module rspamd_task @@ -1184,7 +1185,7 @@ lua_task_get_content (lua_State * L) rspamd_lua_setclass (L, "rspamd{text}", -1); t->len = task->msg.len; t->start = task->msg.begin; - t->own = FALSE; + t->flags = 0; } else { return luaL_error (L, "invalid arguments"); @@ -1213,7 +1214,7 @@ lua_task_get_rawbody (lua_State * L) t->start = task->msg.begin; } - t->own = FALSE; + t->flags = 0; } else { return luaL_error (L, "invalid arguments"); @@ -1311,7 +1312,7 @@ lua_task_get_request_header (lua_State *L) rspamd_lua_setclass (L, "rspamd{text}", -1); t->start = hdr->begin; t->len = hdr->len; - t->own = FALSE; + t->flags = 0; return 1; } @@ -1490,7 +1491,7 @@ lua_task_get_raw_headers (lua_State *L) rspamd_lua_setclass (L, "rspamd{text}", -1); t->start = task->raw_headers_content.begin; t->len = task->raw_headers_content.len; - t->own = FALSE; + t->flags = 0; } else { return luaL_error (L, "invalid arguments"); @@ -3473,8 +3474,16 @@ lua_text_gc (lua_State *L) { struct rspamd_lua_text *t = lua_check_text (L, 1); - if (t != NULL && t->own) { - g_free ((gpointer)t->start); + if (t != NULL) { + if (t->flags & RSPAMD_TEXT_FLAG_OWN) { + if (t->flags & RSPAMD_TEXT_FLAG_MMAPED) { + munmap ((gpointer)t->start, t->len); + } + else { + g_free ((gpointer)t->start); + } + } + } return 0; |