comparison src/http/ngx_http_spdy.h @ 5549:39d7eef2e332

SPDY: protocol implementation switched to spdy/3.1.
author Valentin Bartenev <vbart@nginx.com>
date Fri, 31 Jan 2014 19:17:26 +0400
parents 01e2a5bcdd8f
children 2bc609a4b516
comparison
equal deleted inserted replaced
5548:4d47722d76b2 5549:39d7eef2e332
13 #include <ngx_http.h> 13 #include <ngx_http.h>
14 14
15 #include <zlib.h> 15 #include <zlib.h>
16 16
17 17
18 #define NGX_SPDY_VERSION 2 18 #define NGX_SPDY_VERSION 3
19 19
20 #define NGX_SPDY_NPN_ADVERTISE "\x06spdy/2" 20 #define NGX_SPDY_NPN_ADVERTISE "\x08spdy/3.1"
21 #define NGX_SPDY_NPN_NEGOTIATED "spdy/2" 21 #define NGX_SPDY_NPN_NEGOTIATED "spdy/3.1"
22 22
23 #define NGX_SPDY_STATE_BUFFER_SIZE 16 23 #define NGX_SPDY_STATE_BUFFER_SIZE 16
24 24
25 #define NGX_SPDY_CTL_BIT 1 25 #define NGX_SPDY_CTL_BIT 1
26 26
27 #define NGX_SPDY_SYN_STREAM 1 27 #define NGX_SPDY_SYN_STREAM 1
28 #define NGX_SPDY_SYN_REPLY 2 28 #define NGX_SPDY_SYN_REPLY 2
29 #define NGX_SPDY_RST_STREAM 3 29 #define NGX_SPDY_RST_STREAM 3
30 #define NGX_SPDY_SETTINGS 4 30 #define NGX_SPDY_SETTINGS 4
31 #define NGX_SPDY_NOOP 5
32 #define NGX_SPDY_PING 6 31 #define NGX_SPDY_PING 6
33 #define NGX_SPDY_GOAWAY 7 32 #define NGX_SPDY_GOAWAY 7
34 #define NGX_SPDY_HEADERS 8 33 #define NGX_SPDY_HEADERS 8
34 #define NGX_SPDY_WINDOW_UPDATE 9
35 35
36 #define NGX_SPDY_FRAME_HEADER_SIZE 8 36 #define NGX_SPDY_FRAME_HEADER_SIZE 8
37 37
38 #define NGX_SPDY_SID_SIZE 4 38 #define NGX_SPDY_SID_SIZE 4
39 #define NGX_SPDY_DELTA_SIZE 4
39 40
40 #define NGX_SPDY_SYN_STREAM_SIZE 10 41 #define NGX_SPDY_SYN_STREAM_SIZE 10
41 #define NGX_SPDY_SYN_REPLY_SIZE 6 42 #define NGX_SPDY_SYN_REPLY_SIZE 4
42 #define NGX_SPDY_RST_STREAM_SIZE 8 43 #define NGX_SPDY_RST_STREAM_SIZE 8
43 #define NGX_SPDY_PING_SIZE 4 44 #define NGX_SPDY_PING_SIZE 4
44 #define NGX_SPDY_GOAWAY_SIZE 4 45 #define NGX_SPDY_GOAWAY_SIZE 8
45 #define NGX_SPDY_NV_NUM_SIZE 2 46 #define NGX_SPDY_WINDOW_UPDATE_SIZE 8
46 #define NGX_SPDY_NV_NLEN_SIZE 2 47 #define NGX_SPDY_NV_NUM_SIZE 4
47 #define NGX_SPDY_NV_VLEN_SIZE 2 48 #define NGX_SPDY_NV_NLEN_SIZE 4
49 #define NGX_SPDY_NV_VLEN_SIZE 4
48 #define NGX_SPDY_SETTINGS_NUM_SIZE 4 50 #define NGX_SPDY_SETTINGS_NUM_SIZE 4
49 #define NGX_SPDY_SETTINGS_IDF_SIZE 4 51 #define NGX_SPDY_SETTINGS_FID_SIZE 4
50 #define NGX_SPDY_SETTINGS_VAL_SIZE 4 52 #define NGX_SPDY_SETTINGS_VAL_SIZE 4
51 53
52 #define NGX_SPDY_SETTINGS_PAIR_SIZE \ 54 #define NGX_SPDY_SETTINGS_PAIR_SIZE \
53 (NGX_SPDY_SETTINGS_IDF_SIZE + NGX_SPDY_SETTINGS_VAL_SIZE) 55 (NGX_SPDY_SETTINGS_FID_SIZE + NGX_SPDY_SETTINGS_VAL_SIZE)
54 56
55 #define NGX_SPDY_HIGHEST_PRIORITY 0 57 #define NGX_SPDY_HIGHEST_PRIORITY 0
56 #define NGX_SPDY_LOWEST_PRIORITY 3 58 #define NGX_SPDY_LOWEST_PRIORITY 7
57 59
58 #define NGX_SPDY_FLAG_FIN 0x01 60 #define NGX_SPDY_FLAG_FIN 0x01
59 #define NGX_SPDY_FLAG_UNIDIRECTIONAL 0x02 61 #define NGX_SPDY_FLAG_UNIDIRECTIONAL 0x02
60 #define NGX_SPDY_FLAG_CLEAR_SETTINGS 0x01 62 #define NGX_SPDY_FLAG_CLEAR_SETTINGS 0x01
61 63
76 struct ngx_http_spdy_connection_s { 78 struct ngx_http_spdy_connection_s {
77 ngx_connection_t *connection; 79 ngx_connection_t *connection;
78 ngx_http_connection_t *http_connection; 80 ngx_http_connection_t *http_connection;
79 81
80 ngx_uint_t processing; 82 ngx_uint_t processing;
83
84 size_t send_window;
85 size_t recv_window;
86 size_t init_window;
87
88 ngx_queue_t waiting;
81 89
82 u_char buffer[NGX_SPDY_STATE_BUFFER_SIZE]; 90 u_char buffer[NGX_SPDY_STATE_BUFFER_SIZE];
83 size_t buffer_used; 91 size_t buffer_used;
84 ngx_http_spdy_handler_pt handler; 92 ngx_http_spdy_handler_pt handler;
85 93
117 ngx_http_spdy_stream_t *index; 125 ngx_http_spdy_stream_t *index;
118 126
119 ngx_uint_t header_buffers; 127 ngx_uint_t header_buffers;
120 ngx_uint_t queued; 128 ngx_uint_t queued;
121 129
130 /*
131 * A change to SETTINGS_INITIAL_WINDOW_SIZE could cause the
132 * send_window to become negative, hence it's signed.
133 */
134 ssize_t send_window;
135 size_t recv_window;
136
122 ngx_http_spdy_out_frame_t *free_frames; 137 ngx_http_spdy_out_frame_t *free_frames;
123 ngx_chain_t *free_data_headers; 138 ngx_chain_t *free_data_headers;
124 ngx_chain_t *free_bufs; 139 ngx_chain_t *free_bufs;
125 140
126 ngx_queue_t queue; 141 ngx_queue_t queue;
127 142
128 unsigned priority:2; 143 unsigned priority:3;
129 unsigned handled:1; 144 unsigned handled:1;
130 unsigned blocked:1; 145 unsigned blocked:1;
146 unsigned exhausted:1;
131 unsigned in_closed:1; 147 unsigned in_closed:1;
132 unsigned out_closed:1; 148 unsigned out_closed:1;
133 unsigned skip_data:2; 149 unsigned skip_data:2;
134 }; 150 };
135 151
228 #define ngx_spdy_frame_write_head(p, t) \ 244 #define ngx_spdy_frame_write_head(p, t) \
229 ngx_spdy_frame_aligned_write_uint32(p, ngx_spdy_ctl_frame_head(t)) 245 ngx_spdy_frame_aligned_write_uint32(p, ngx_spdy_ctl_frame_head(t))
230 246
231 #define ngx_spdy_frame_write_flags_and_len(p, f, l) \ 247 #define ngx_spdy_frame_write_flags_and_len(p, f, l) \
232 ngx_spdy_frame_aligned_write_uint32(p, (f) << 24 | (l)) 248 ngx_spdy_frame_aligned_write_uint32(p, (f) << 24 | (l))
233 249 #define ngx_spdy_frame_write_flags_and_id(p, f, i) \
234 #define ngx_spdy_frame_write_sid ngx_spdy_frame_aligned_write_uint32 250 ngx_spdy_frame_aligned_write_uint32(p, (f) << 24 | (i))
251
252 #define ngx_spdy_frame_write_sid ngx_spdy_frame_aligned_write_uint32
253 #define ngx_spdy_frame_write_window ngx_spdy_frame_aligned_write_uint32
235 254
236 #endif /* _NGX_HTTP_SPDY_H_INCLUDED_ */ 255 #endif /* _NGX_HTTP_SPDY_H_INCLUDED_ */