Klaus Demo nginx / 8d568c7
Sub filter: switched to ngx_chain_get_free_buf(). No functional changes. Maxim Dounin 9 years ago
1 changed file(s) with 26 addition(s) and 65 deletion(s). Raw diff Collapse all Expand all
267267
268268 if (ctx->saved.len) {
269269
270 if (ctx->free) {
271 cl = ctx->free;
272 ctx->free = ctx->free->next;
273 b = cl->buf;
274 ngx_memzero(b, sizeof(ngx_buf_t));
275
276 } else {
277 b = ngx_calloc_buf(r->pool);
278 if (b == NULL) {
279 return NGX_ERROR;
280 }
281
282 cl = ngx_alloc_chain_link(r->pool);
283 if (cl == NULL) {
284 return NGX_ERROR;
285 }
286
287 cl->buf = b;
270 cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
271 if (cl == NULL) {
272 return NGX_ERROR;
288273 }
274
275 b = cl->buf;
276
277 ngx_memzero(b, sizeof(ngx_buf_t));
289278
290279 b->pos = ngx_pnalloc(r->pool, ctx->saved.len);
291280 if (b->pos == NULL) {
302291 ctx->saved.len = 0;
303292 }
304293
305 if (ctx->free) {
306 cl = ctx->free;
307 ctx->free = ctx->free->next;
308 b = cl->buf;
309
310 } else {
311 b = ngx_alloc_buf(r->pool);
312 if (b == NULL) {
313 return NGX_ERROR;
314 }
315
316 cl = ngx_alloc_chain_link(r->pool);
317 if (cl == NULL) {
318 return NGX_ERROR;
319 }
320
321 cl->buf = b;
322 }
294 cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
295 if (cl == NULL) {
296 return NGX_ERROR;
297 }
298
299 b = cl->buf;
323300
324301 ngx_memcpy(b, ctx->buf, sizeof(ngx_buf_t));
325302
334311 b->file_pos += b->pos - ctx->buf->pos;
335312 }
336313
337 cl->next = NULL;
338314 *ctx->last_out = cl;
339315 ctx->last_out = &cl->next;
340316 }
355331
356332 /* rc == NGX_OK */
357333
358 b = ngx_calloc_buf(r->pool);
359 if (b == NULL) {
360 return NGX_ERROR;
361 }
362
363 cl = ngx_alloc_chain_link(r->pool);
334 cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
364335 if (cl == NULL) {
365336 return NGX_ERROR;
366337 }
338
339 b = cl->buf;
340
341 ngx_memzero(b, sizeof(ngx_buf_t));
367342
368343 slcf = ngx_http_get_module_loc_conf(r, ngx_http_sub_filter_module);
369344
385360 b->sync = 1;
386361 }
387362
388 cl->buf = b;
389 cl->next = NULL;
390363 *ctx->last_out = cl;
391364 ctx->last_out = &cl->next;
392365
397370
398371 if (ctx->buf->last_buf || ngx_buf_in_memory(ctx->buf)) {
399372 if (b == NULL) {
400 if (ctx->free) {
401 cl = ctx->free;
402 ctx->free = ctx->free->next;
403 b = cl->buf;
404 ngx_memzero(b, sizeof(ngx_buf_t));
405
406 } else {
407 b = ngx_calloc_buf(r->pool);
408 if (b == NULL) {
409 return NGX_ERROR;
410 }
411
412 cl = ngx_alloc_chain_link(r->pool);
413 if (cl == NULL) {
414 return NGX_ERROR;
415 }
416
417 cl->buf = b;
418 }
373 cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
374 if (cl == NULL) {
375 return NGX_ERROR;
376 }
377
378 b = cl->buf;
379
380 ngx_memzero(b, sizeof(ngx_buf_t));
419381
420382 b->sync = 1;
421383
422 cl->next = NULL;
423384 *ctx->last_out = cl;
424385 ctx->last_out = &cl->next;
425386 }