hc = r->http_connection;
b = r->header_in;
//一般情况下,当解析完header_in之后,pos会设置为last。也就是读取到的数据刚好是一个完整的http请求.当pos小于last,则说明可能是一个pipeline请求。
if (b->pos last) {
/* the pipelined request */
if (b != c->buffer) {
/*
* If the large header buffers were allocated while the previous
* request processing then we do not use c->buffer for
* the pipelined request (see ngx_http_init_request()).
*
* Now we would move the large header buffers to the free list.
*/
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
//如果free为空,则新建
if (hc-> free == NULL) {
//可以看到是large_client_headers的个数
hc-> free = ngx_palloc(c->pool,
cscf->large_client_header_buffers.num *
sizeof (ngx_buf_t *));
if (hc-> free == NULL) {
ngx_http_close_request(r, 0);
return ;
}
}
//然后清理当前的request的busy
for (i = 0; i nbusy - 1; i++) {
f = hc->busy[i];
hc-> free [hc->nfree++] = f;
f->pos = f->start;
f->last = f->start;
}
//保存当前的header_in buf,以便与下次给free使用。
hc->busy[0] = b;
hc->nbusy = 1;
}
}
|