mirror of
https://github.com/nginx/nginx.git
synced 2024-12-20 14:13:33 -06:00
Moved the code for adjusting sent buffers in a separate function.
This commit is contained in:
parent
8b6f1c7bb0
commit
4aac91049f
@ -218,3 +218,49 @@ ngx_chain_update_chains(ngx_pool_t *p, ngx_chain_t **free, ngx_chain_t **busy,
|
||||
*free = cl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ngx_chain_t *
|
||||
ngx_handle_sent_chain(ngx_chain_t *in, off_t sent)
|
||||
{
|
||||
off_t size;
|
||||
|
||||
for ( /* void */ ; in; in = in->next) {
|
||||
|
||||
if (ngx_buf_special(in->buf)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sent == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
size = ngx_buf_size(in->buf);
|
||||
|
||||
if (sent >= size) {
|
||||
sent -= size;
|
||||
|
||||
if (ngx_buf_in_memory(in->buf)) {
|
||||
in->buf->pos = in->buf->last;
|
||||
}
|
||||
|
||||
if (in->buf->in_file) {
|
||||
in->buf->file_pos = in->buf->file_last;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_buf_in_memory(in->buf)) {
|
||||
in->buf->pos += (size_t) sent;
|
||||
}
|
||||
|
||||
if (in->buf->in_file) {
|
||||
in->buf->file_pos += sent;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
@ -158,5 +158,6 @@ ngx_chain_t *ngx_chain_get_free_buf(ngx_pool_t *p, ngx_chain_t **free);
|
||||
void ngx_chain_update_chains(ngx_pool_t *p, ngx_chain_t **free,
|
||||
ngx_chain_t **busy, ngx_chain_t **out, ngx_buf_tag_t tag);
|
||||
|
||||
ngx_chain_t *ngx_handle_sent_chain(ngx_chain_t *in, off_t sent);
|
||||
|
||||
#endif /* _NGX_BUF_H_INCLUDED_ */
|
||||
|
@ -317,42 +317,7 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
|
||||
c->sent += sent;
|
||||
|
||||
for ( /* void */ ; in; in = in->next) {
|
||||
|
||||
if (ngx_buf_special(in->buf)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sent == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
size = ngx_buf_size(in->buf);
|
||||
|
||||
if (sent >= size) {
|
||||
sent -= size;
|
||||
|
||||
if (ngx_buf_in_memory(in->buf)) {
|
||||
in->buf->pos = in->buf->last;
|
||||
}
|
||||
|
||||
if (in->buf->in_file) {
|
||||
in->buf->file_pos = in->buf->file_last;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_buf_in_memory(in->buf)) {
|
||||
in->buf->pos += (size_t) sent;
|
||||
}
|
||||
|
||||
if (in->buf->in_file) {
|
||||
in->buf->file_pos += sent;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
in = ngx_handle_sent_chain(in, sent);
|
||||
|
||||
if (eintr) {
|
||||
continue;
|
||||
|
@ -368,42 +368,7 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
|
||||
c->sent += sent;
|
||||
|
||||
for ( /* void */ ; in; in = in->next) {
|
||||
|
||||
if (ngx_buf_special(in->buf)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sent == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
size = ngx_buf_size(in->buf);
|
||||
|
||||
if (sent >= size) {
|
||||
sent -= size;
|
||||
|
||||
if (ngx_buf_in_memory(in->buf)) {
|
||||
in->buf->pos = in->buf->last;
|
||||
}
|
||||
|
||||
if (in->buf->in_file) {
|
||||
in->buf->file_pos = in->buf->file_last;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_buf_in_memory(in->buf)) {
|
||||
in->buf->pos += (size_t) sent;
|
||||
}
|
||||
|
||||
if (in->buf->in_file) {
|
||||
in->buf->file_pos += sent;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
in = ngx_handle_sent_chain(in, sent);
|
||||
|
||||
#if (NGX_HAVE_AIO_SENDFILE)
|
||||
if (c->busy_sendfile) {
|
||||
|
@ -325,42 +325,7 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
|
||||
c->sent += sent;
|
||||
|
||||
for ( /* void */ ; in; in = in->next) {
|
||||
|
||||
if (ngx_buf_special(in->buf)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sent == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
size = ngx_buf_size(in->buf);
|
||||
|
||||
if (sent >= size) {
|
||||
sent -= size;
|
||||
|
||||
if (ngx_buf_in_memory(in->buf)) {
|
||||
in->buf->pos = in->buf->last;
|
||||
}
|
||||
|
||||
if (in->buf->in_file) {
|
||||
in->buf->file_pos = in->buf->file_last;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_buf_in_memory(in->buf)) {
|
||||
in->buf->pos += (size_t) sent;
|
||||
}
|
||||
|
||||
if (in->buf->in_file) {
|
||||
in->buf->file_pos += sent;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
in = ngx_handle_sent_chain(in, sent);
|
||||
|
||||
if (eintr) {
|
||||
continue;
|
||||
|
@ -207,42 +207,7 @@ ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
|
||||
c->sent += sent;
|
||||
|
||||
for ( /* void */ ; in; in = in->next) {
|
||||
|
||||
if (ngx_buf_special(in->buf)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sent == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
size = ngx_buf_size(in->buf);
|
||||
|
||||
if ((off_t) sent >= size) {
|
||||
sent = (size_t) ((off_t) sent - size);
|
||||
|
||||
if (ngx_buf_in_memory(in->buf)) {
|
||||
in->buf->pos = in->buf->last;
|
||||
}
|
||||
|
||||
if (in->buf->in_file) {
|
||||
in->buf->file_pos = in->buf->file_last;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_buf_in_memory(in->buf)) {
|
||||
in->buf->pos += sent;
|
||||
}
|
||||
|
||||
if (in->buf->in_file) {
|
||||
in->buf->file_pos += sent;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
in = ngx_handle_sent_chain(in, sent);
|
||||
|
||||
if (eintr) {
|
||||
continue;
|
||||
|
@ -143,29 +143,7 @@ ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
|
||||
c->sent += sent;
|
||||
|
||||
for (cl = in; cl; cl = cl->next) {
|
||||
|
||||
if (ngx_buf_special(cl->buf)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sent == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
size = cl->buf->last - cl->buf->pos;
|
||||
|
||||
if (sent >= size) {
|
||||
sent -= size;
|
||||
cl->buf->pos = cl->buf->last;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
cl->buf->pos += sent;
|
||||
|
||||
break;
|
||||
}
|
||||
cl = ngx_handle_sent_chain(in, sent);
|
||||
|
||||
if (eintr) {
|
||||
continue;
|
||||
|
@ -119,29 +119,7 @@ ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
|
||||
c->sent += sent;
|
||||
|
||||
for (cl = in; cl; cl = cl->next) {
|
||||
|
||||
if (ngx_buf_special(cl->buf)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sent == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
size = cl->buf->last - cl->buf->pos;
|
||||
|
||||
if (sent >= size) {
|
||||
sent -= size;
|
||||
cl->buf->pos = cl->buf->last;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
cl->buf->pos += sent;
|
||||
|
||||
break;
|
||||
}
|
||||
cl = ngx_handle_sent_chain(in, sent);
|
||||
|
||||
if (!complete) {
|
||||
wev->ready = 0;
|
||||
@ -308,28 +286,7 @@ ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
|
||||
c->sent += sent;
|
||||
|
||||
for (cl = in; cl && sent > 0; cl = cl->next) {
|
||||
if (ngx_buf_special(cl->buf)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sent == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
size = cl->buf->last - cl->buf->pos;
|
||||
|
||||
if (sent >= size) {
|
||||
sent -= size;
|
||||
cl->buf->pos = cl->buf->last;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
cl->buf->pos += sent;
|
||||
|
||||
break;
|
||||
}
|
||||
cl = ngx_handle_sent_chain(in, sent);
|
||||
|
||||
if (cl) {
|
||||
wev->ready = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user