瀏覽代碼

timed out connections now errors instead of 0/0 and done on cleaning

tags/v0.4
Brice Figureau 18 年之前
父節點
當前提交
51262f2755
共有 1 個文件被更改,包括 20 次插入1 次删除
  1. 20
    1
      ngx_http_uploadprogress_module.c

+ 20
- 1
ngx_http_uploadprogress_module.c 查看文件

@@ -271,8 +271,9 @@ ngx_http_uploadprogress_content_handler(ngx_http_request_t *r)
271 271
     rc = upcf->handler(r);
272 272
 
273 273
     /* bail out if error */
274
-    if (rc >= NGX_HTTP_SPECIAL_RESPONSE)
274
+    if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
275 275
       return rc;
276
+    }
276 277
     
277 278
     /* request is OK, hijack the read_event_handler */
278 279
     ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_uploadprogress_module_ctx_t));
@@ -305,6 +306,24 @@ static void ngx_http_uploadprogress_event_handler(ngx_http_request_t *r)
305 306
 
306 307
     /* check that the request/connection is still OK */
307 308
     if (r->headers_out.status >= NGX_HTTP_SPECIAL_RESPONSE) {
309
+        /* should mark up as error */
310
+        id = get_tracking_id(r);
311
+        if (id != NULL) {
312
+            upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
313
+            if (upcf != NULL && upcf->shm_zone != NULL) {
314
+                ctx = upcf->shm_zone->data;
315
+
316
+                /* get the original connection of the upload */
317
+                shpool = (ngx_slab_pool_t *) upcf->shm_zone->shm.addr;
318
+
319
+                ngx_shmtx_lock(&shpool->mutex);
320
+                up = find_node(id, ctx, ngx_cycle->log);
321
+                if (up != NULL) {
322
+                    up->err_status = r->headers_out.status;
323
+                }
324
+                ngx_shmtx_unlock(&shpool->mutex);
325
+            }
326
+        }
308 327
         return;
309 328
     }
310 329
 

Loading…
取消
儲存