diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-09-09 12:39:38 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-09-09 13:51:26 +0100 |
commit | 9a1b912929527accc88b9bdb48c63a5855f64c36 (patch) | |
tree | f7e3002a1bab1bb54ac3cd0f1db715fe585b1f8a /src/libserver/task.c | |
parent | 448c39791528275606f5c5350f6298de06a18462 (diff) | |
download | rspamd-9a1b912929527accc88b9bdb48c63a5855f64c36.tar.gz rspamd-9a1b912929527accc88b9bdb48c63a5855f64c36.zip |
[Feature] Preserve decompression context between tasks
Diffstat (limited to 'src/libserver/task.c')
-rw-r--r-- | src/libserver/task.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/libserver/task.c b/src/libserver/task.c index 95c3375b2..950564b2d 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -494,6 +494,14 @@ rspamd_task_load_message (struct rspamd_task *task, gsize outlen, r; gulong dict_id; + if (!rspamd_libs_reset_decompression (task->cfg->libs_ctx)) { + g_set_error (&task->err, rspamd_task_quark(), + RSPAMD_PROTOCOL_ERROR, + "Cannot decompress, decompressor init failed"); + + return FALSE; + } + tok = rspamd_task_get_request_header (task, "dictionary"); if (tok != NULL) { @@ -518,19 +526,10 @@ rspamd_task_load_message (struct rspamd_task *task, return FALSE; } - - zstream = ZSTD_createDStream (); - g_assert (zstream != NULL); - g_assert (!ZSTD_isError (ZSTD_initDStream_usingDict (zstream, - task->cfg->libs_ctx->in_dict->dict, - task->cfg->libs_ctx->in_dict->size))); - } - else { - zstream = ZSTD_createDStream (); - g_assert (zstream != NULL); - g_assert (!ZSTD_isError (ZSTD_initDStream (zstream))); } + zstream = task->cfg->libs_ctx->in_zstream; + zin.pos = 0; zin.src = start; zin.size = len; @@ -548,9 +547,9 @@ rspamd_task_load_message (struct rspamd_task *task, r = ZSTD_decompressStream (zstream, &zout, &zin); if (ZSTD_isError (r)) { - g_set_error (&task->err, rspamd_task_quark(), RSPAMD_PROTOCOL_ERROR, - "Decompression error"); - ZSTD_freeDStream (zstream); + g_set_error (&task->err, rspamd_task_quark(), + RSPAMD_PROTOCOL_ERROR, + "Decompression error: %s", ZSTD_getErrorName (r)); return FALSE; } @@ -562,7 +561,6 @@ rspamd_task_load_message (struct rspamd_task *task, } } - ZSTD_freeDStream (zstream); rspamd_mempool_add_destructor (task->task_pool, g_free, zout.dst); task->msg.begin = zout.dst; task->msg.len = zout.pos; |