Skip to content

Commit 6be764e

Browse files
authored
fix: avoid using deprecated ZSTD_initCStream_usingCDict if zstd version >= 1.5.0 (tokers#28)
Signed-off-by: tokers <zhangchao.1995@bytedance.com>
1 parent 4582ef9 commit 6be764e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

filter/ngx_http_zstd_filter_module.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,25 @@ ngx_http_zstd_filter_create_cstream(ngx_http_request_t *r,
603603
/* TODO use the advanced initialize functions */
604604

605605
if (zlcf->dict) {
606+
#if ZSTD_VERSION_NUMBER >= 10500
607+
rc = ZSTD_CCtx_reset(cstream, ZSTD_reset_session_only);
608+
if (ZSTD_isError(rc)) {
609+
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
610+
"ZSTD_CCtx_reset() failed: %s",
611+
ZSTD_getErrorName(rc));
612+
goto failed;
613+
}
614+
615+
rc = ZSTD_CCtx_refCDict(cstream, zlcf->dict);
616+
if (ZSTD_isError(rc)) {
617+
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
618+
"ZSTD_CCtx_refCDict() failed: %s",
619+
ZSTD_getErrorName(rc));
620+
goto failed;
621+
}
622+
#else
606623
rc = ZSTD_initCStream_usingCDict(cstream, zlcf->dict);
624+
#endif
607625
if (ZSTD_isError(rc)) {
608626
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
609627
"ZSTD_initCStream_usingCDict() failed: %s",

0 commit comments

Comments
 (0)