comparison src/event/ngx_event_pipe.c @ 4119:b66712cde67d

Upstream: pipe length and input_filter_init in buffered mode. As long as ngx_event_pipe() has more data read from upstream than specified in p->length it's passed to input filter even if buffer isn't yet full. This allows to process data with known length without relying on connection close to signal data end. By default p->length is set to -1 in upstream module, i.e. end of data is indicated by connection close. To set it from per-protocol handlers upstream input_filter_init() now called in buffered mode (as well as in unbuffered mode).
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 15 Sep 2011 19:00:47 +0000
parents 5db098f97e0e
children d8e24515176e
comparison
equal deleted inserted replaced
4118:dbddec65fdab 4119:b66712cde67d
390 cl->buf->last - cl->buf->pos, 390 cl->buf->last - cl->buf->pos,
391 cl->buf->file_pos, 391 cl->buf->file_pos,
392 cl->buf->file_last - cl->buf->file_pos); 392 cl->buf->file_last - cl->buf->file_pos);
393 } 393 }
394 394
395 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
396 "pipe length: %O", p->length);
397
395 #endif 398 #endif
399
400 if (p->free_raw_bufs && p->length != -1) {
401 cl = p->free_raw_bufs;
402
403 if (cl->buf->last - cl->buf->pos >= p->length) {
404
405 /* STUB */ cl->buf->num = p->num++;
406
407 if (p->input_filter(p, cl->buf) == NGX_ERROR) {
408 return NGX_ABORT;
409 }
410
411 p->free_raw_bufs = cl->next;
412 }
413 }
414
415 if (p->length == 0) {
416 p->upstream_done = 1;
417 p->read = 1;
418 }
396 419
397 if ((p->upstream_eof || p->upstream_error) && p->free_raw_bufs) { 420 if ((p->upstream_eof || p->upstream_error) && p->free_raw_bufs) {
398 421
399 /* STUB */ p->free_raw_bufs->buf->num = p->num++; 422 /* STUB */ p->free_raw_bufs->buf->num = p->num++;
400 423
846 } else { 869 } else {
847 p->in = cl; 870 p->in = cl;
848 } 871 }
849 p->last_in = &cl->next; 872 p->last_in = &cl->next;
850 873
874 if (p->length == -1) {
875 return NGX_OK;
876 }
877
878 p->length -= b->last - b->pos;
879
851 return NGX_OK; 880 return NGX_OK;
852 } 881 }
853 882
854 883
855 static ngx_inline void 884 static ngx_inline void