diff src/http/ngx_http_spdy.c @ 5528:d5de6c25b759

SPDY: use frame->next pointer to chain free frames. There is no need in separate "free" pointer and like it is for ngx_chain_t the "next" pointer can be used. But after this change successfully handled frame should not be accessed, so the frame handling cycle was improved to store pointer to the next frame before processing. Also worth noting that initializing "free" pointer to NULL in the original code was surplus.
author Valentin Bartenev <vbart@nginx.com>
date Wed, 22 Jan 2014 04:58:19 +0400
parents f3f7b72ca6e9
children e4adaa47af65
line wrap: on
line diff
--- a/src/http/ngx_http_spdy.c
+++ b/src/http/ngx_http_spdy.c
@@ -527,7 +527,9 @@ ngx_http_spdy_send_output_queue(ngx_http
         }
     }
 
-    for ( /* void */ ; out; out = out->next) {
+    for ( /* void */ ; out; out = fn) {
+        fn = out->next;
+
         if (out->handler(sc, out) != NGX_OK) {
             out->blocked = 1;
             out->priority = NGX_SPDY_HIGHEST_PRIORITY;
@@ -1644,7 +1646,7 @@ ngx_http_spdy_get_ctl_frame(ngx_http_spd
     frame = sc->free_ctl_frames;
 
     if (frame) {
-        sc->free_ctl_frames = frame->free;
+        sc->free_ctl_frames = frame->next;
 
         cl = frame->first;
         cl->buf->pos = cl->buf->start;
@@ -1674,8 +1676,6 @@ ngx_http_spdy_get_ctl_frame(ngx_http_spd
         frame->stream = NULL;
     }
 
-    frame->free = NULL;
-
 #if (NGX_DEBUG)
     if (size > NGX_SPDY_CTL_FRAME_BUFFER_SIZE - NGX_SPDY_FRAME_HEADER_SIZE) {
         ngx_log_error(NGX_LOG_ALERT, sc->pool->log, 0,
@@ -1705,7 +1705,7 @@ ngx_http_spdy_ctl_frame_handler(ngx_http
         return NGX_AGAIN;
     }
 
-    frame->free = sc->free_ctl_frames;
+    frame->next = sc->free_ctl_frames;
     sc->free_ctl_frames = frame;
 
     return NGX_OK;