#include <ngx_event.h>
-#define NGX_WSABUFS 8
+#define NGX_WSABUFS 64
ngx_chain_t *
vec.elts = wsabufs;
vec.size = sizeof(WSABUF);
- vec.nalloc = NGX_WSABUFS;
+ vec.nalloc = ngx_min(NGX_WSABUFS, ngx_max_wsabufs);
vec.pool = c->pool;
for ( ;; ) {
/* create the WSABUF and coalesce the neighbouring bufs */
- for (cl = in;
- cl && vec.nelts < ngx_max_wsabufs && send < limit;
- cl = cl->next)
- {
+ for (cl = in; cl && send < limit; cl = cl->next) {
+
if (ngx_buf_special(cl->buf)) {
continue;
}
wsabuf->len += cl->buf->last - cl->buf->pos;
} else {
+ if (vec.nelts == vec.nalloc) {
+ break;
+ }
+
wsabuf = ngx_array_push(&vec);
if (wsabuf == NULL) {
return NGX_CHAIN_ERROR;
vec.elts = wsabufs;
vec.nelts = 0;
vec.size = sizeof(WSABUF);
- vec.nalloc = NGX_WSABUFS;
+ vec.nalloc = ngx_min(NGX_WSABUFS, ngx_max_wsabufs);
vec.pool = c->pool;
send = 0;
/* create the WSABUF and coalesce the neighbouring bufs */
- for (cl = in;
- cl && vec.nelts < ngx_max_wsabufs && send < limit;
- cl = cl->next)
- {
+ for (cl = in; cl && send < limit; cl = cl->next) {
+
if (ngx_buf_special(cl->buf)) {
continue;
}
wsabuf->len += cl->buf->last - cl->buf->pos;
} else {
+ if (vec.nelts == vec.nalloc) {
+ break;
+ }
+
wsabuf = ngx_array_push(&vec);
if (wsabuf == NULL) {
return NGX_CHAIN_ERROR;