comparison src/event/ngx_event_openssl.c @ 5882:ec81934727a1

Core: added limit to recv_chain().
author Roman Arutyunyan <arut@nginx.com>
date Tue, 28 Oct 2014 12:29:58 +0300
parents ca63fc5ed9b1
children 42520df85ebb
comparison
equal deleted inserted replaced
5881:ee9230cd4bda 5882:ec81934727a1
1183 c->ssl->handler(c); 1183 c->ssl->handler(c);
1184 } 1184 }
1185 1185
1186 1186
1187 ssize_t 1187 ssize_t
1188 ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl) 1188 ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit)
1189 { 1189 {
1190 u_char *last; 1190 u_char *last;
1191 ssize_t n, bytes; 1191 ssize_t n, bytes, size;
1192 ngx_buf_t *b; 1192 ngx_buf_t *b;
1193 1193
1194 bytes = 0; 1194 bytes = 0;
1195 1195
1196 b = cl->buf; 1196 b = cl->buf;
1197 last = b->last; 1197 last = b->last;
1198 1198
1199 for ( ;; ) { 1199 for ( ;; ) {
1200 1200 size = b->end - last;
1201 n = ngx_ssl_recv(c, last, b->end - last); 1201
1202 if (limit) {
1203 if (bytes >= limit) {
1204 return bytes;
1205 }
1206
1207 if (bytes + size > limit) {
1208 size = (ssize_t) (limit - bytes);
1209 }
1210 }
1211
1212 n = ngx_ssl_recv(c, last, size);
1202 1213
1203 if (n > 0) { 1214 if (n > 0) {
1204 last += n; 1215 last += n;
1205 bytes += n; 1216 bytes += n;
1206 1217