Selaa lähdekoodia

Fix compilation issues with nginx 1.23 and later

Based on patch provided in:
https://github.com/masterzen/nginx-upload-progress-module/issues/56#issuecomment-1165886072

Fixes: #56
Co-authored-by: Sergey Maslov <sergey@maslov.biz>
Co-authored-by: Vadim A. Misbakh-Soloviov <git@mva.name>
Co-authored-by: Benny Baumann <BenBE@geshi.org>
Signed-off-by: Vadim A. Misbakh-Soloviov <git@mva.name>
Signed-off-by: Benny Baumann <BenBE@geshi.org>
tags/v0.9.3
Sergey Maslov 1 vuosi sitten
vanhempi
commit
83a4c76a34
1 muutettua tiedostoa jossa 13 lisäystä ja 19 poistoa
  1. 13
    19
      ngx_http_uploadprogress_module.c

+ 13
- 19
ngx_http_uploadprogress_module.c Näytä tiedosto

@@ -559,12 +559,12 @@ ngx_http_reportuploads_handler(ngx_http_request_t * r)
559 559
     ngx_chain_t                      out;
560 560
     ngx_int_t                        rc, found=0, done=0, err_status=0;
561 561
     off_t                            rest=0, length=0;
562
-    ngx_uint_t                       len, i;
562
+    ngx_uint_t                       len;
563 563
     ngx_slab_pool_t                 *shpool;
564 564
     ngx_http_uploadprogress_conf_t  *upcf;
565 565
     ngx_http_uploadprogress_ctx_t   *ctx;
566 566
     ngx_http_uploadprogress_node_t  *up;
567
-    ngx_table_elt_t                 *expires, *cc, **ccp;
567
+    ngx_table_elt_t                 *expires, *cc;
568 568
     ngx_http_uploadprogress_state_t  state;
569 569
     ngx_http_uploadprogress_template_t  *t;
570 570
 
@@ -637,6 +637,7 @@ ngx_http_reportuploads_handler(ngx_http_request_t * r)
637 637
         }
638 638
 
639 639
         r->headers_out.expires = expires;
640
+        expires->next = NULL;
640 641
 
641 642
         expires->hash = 1;
642 643
         expires->key.len = sizeof("Expires") - 1;
@@ -646,37 +647,30 @@ ngx_http_reportuploads_handler(ngx_http_request_t * r)
646 647
     len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT");
647 648
     expires->value.len = len - 1;
648 649
 
649
-    ccp = r->headers_out.cache_control.elts;
650
-    if (ccp == NULL) {
650
+    cc = r->headers_out.cache_control;
651 651
 
652
-        if (ngx_array_init(&r->headers_out.cache_control, r->pool,
653
-                           1, sizeof(ngx_table_elt_t *))
654
-            != NGX_OK) {
655
-            return NGX_HTTP_INTERNAL_SERVER_ERROR;
656
-        }
657
-
658
-        ccp = ngx_array_push(&r->headers_out.cache_control);
659
-        if (ccp == NULL) {
660
-            return NGX_HTTP_INTERNAL_SERVER_ERROR;
661
-        }
652
+    if (cc == NULL) {
662 653
 
663 654
         cc = ngx_list_push(&r->headers_out.headers);
664 655
         if (cc == NULL) {
656
+            expires->hash = 0;
665 657
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
666 658
         }
667 659
 
660
+        r->headers_out.cache_control = cc;
661
+        cc->next = NULL;
662
+
668 663
         cc->hash = 1;
669 664
         cc->key.len = sizeof("Cache-Control") - 1;
670 665
         cc->key.data = (u_char *) "Cache-Control";
671 666
 
672
-        *ccp = cc;
673
-
674 667
     } else {
675
-        for (i = 1; i < r->headers_out.cache_control.nelts; i++) {
676
-            ccp[i]->hash = 0;
668
+        for (cc = cc->next; cc; cc = cc->next) {
669
+            cc->hash = 0;
677 670
         }
678 671
 
679
-        cc = ccp[0];
672
+        cc = r->headers_out.cache_control;
673
+        cc->next = NULL;
680 674
     }
681 675
 
682 676
     expires->value.data = (u_char *) "Thu, 01 Jan 1970 00:00:01 GMT";

Loading…
Peruuta
Tallenna