1717
1818
1919typedef struct {
20- ngx_str_t * dict_file ;
20+ ngx_str_t dict_file ;
2121} ngx_http_zstd_main_conf_t ;
2222
2323
@@ -141,7 +141,7 @@ static ngx_command_t ngx_http_zstd_filter_commands[] = {
141141 { ngx_string ("zstd_dict_file" ),
142142 NGX_HTTP_MAIN_CONF |NGX_CONF_TAKE1 ,
143143 ngx_conf_set_str_slot ,
144- NGX_HTTP_LOC_CONF_OFFSET ,
144+ NGX_HTTP_MAIN_CONF_OFFSET ,
145145 offsetof(ngx_http_zstd_main_conf_t , dict_file ),
146146 NULL },
147147
@@ -701,19 +701,14 @@ ngx_http_zstd_init_main_conf(ngx_conf_t *cf, void *conf)
701701{
702702 ngx_http_zstd_main_conf_t * zmcf = conf ;
703703
704- ngx_str_t * dict ;
705-
706- dict = zmcf -> dict_file ;
707- if (dict == NULL || dict -> len == 0 ) {
704+ if (zmcf -> dict_file .len == 0 ) {
708705 return NGX_CONF_OK ;
709706 }
710707
711- if (ngx_conf_full_name (cf -> cycle , dict , 1 ) != NGX_OK ) {
708+ if (ngx_conf_full_name (cf -> cycle , & zmcf -> dict_file , 1 ) != NGX_OK ) {
712709 return NGX_CONF_ERROR ;
713710 }
714711
715- zmcf -> dict_file = dict ;
716-
717712 return NGX_CONF_OK ;
718713}
719714
@@ -780,7 +775,7 @@ ngx_http_zstd_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
780775
781776 zmcf = ngx_http_conf_get_module_main_conf (cf , ngx_http_zstd_filter_module );
782777
783- if (conf -> enable && zmcf -> dict_file ) {
778+ if (conf -> enable && zmcf -> dict_file . len > 0 ) {
784779
785780 if (conf -> level == prev -> level ) {
786781 conf -> dict = prev -> dict ;
@@ -791,7 +786,7 @@ ngx_http_zstd_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
791786 * so we should create a seperate dict object.
792787 */
793788
794- fd = ngx_open_file (zmcf -> dict_file -> data , NGX_FILE_RDONLY ,
789+ fd = ngx_open_file (zmcf -> dict_file . data , NGX_FILE_RDONLY ,
795790 NGX_FILE_OPEN , 0 );
796791
797792 if (fd == NGX_INVALID_FILE ) {
@@ -851,7 +846,7 @@ ngx_http_zstd_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
851846 if (fd != NGX_INVALID_FILE && ngx_close_file (fd ) == NGX_FILE_ERROR ) {
852847 ngx_conf_log_error (NGX_LOG_EMERG , cf , ngx_errno ,
853848 ngx_close_file_n "\"%s\" failed" ,
854- zmcf -> dict_file -> data );
849+ zmcf -> dict_file . data );
855850
856851 rc = NGX_CONF_ERROR ;
857852 }
0 commit comments