]> git.kaiwu.me - nginx.git/commitdiff
fix segfault in SSL if limit_rate is used
authorIgor Sysoev <igor@sysoev.ru>
Tue, 3 Nov 2009 15:38:33 +0000 (15:38 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 3 Nov 2009 15:38:33 +0000 (15:38 +0000)
src/event/ngx_event_openssl.c

index c46a47d1b6a297deb3fe55cd234c22746d6aa797..5388616948efccb7a5698f2c0af2cf160fb3b6ae 100644 (file)
@@ -946,7 +946,7 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 
     for ( ;; ) {
 
-        while (in && buf->last < buf->end) {
+        while (in && buf->last < buf->end && send < limit) {
             if (in->buf->last_buf || in->buf->flush) {
                 flush = 1;
             }
@@ -973,8 +973,8 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
             ngx_memcpy(buf->last, in->buf->pos, size);
 
             buf->last += size;
-
             in->buf->pos += size;
+            send += size;
 
             if (in->buf->pos == in->buf->last) {
                 in = in->next;
@@ -999,7 +999,6 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
         }
 
         buf->pos += n;
-        send += n;
         c->sent += n;
 
         if (n < size) {