Klaus Demo nginx / cd2aa8e
create ssl buffer on demand and free it before keep-alive Igor Sysoev 14 years ago
3 changed file(s) with 38 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
343343 return NGX_ERROR;
344344 }
345345
346 if (flags & NGX_SSL_BUFFER) {
347 sc->buffer = 1;
348
349 sc->buf = ngx_create_temp_buf(c->pool, NGX_SSL_BUFSIZE);
350 if (sc->buf == NULL) {
351 return NGX_ERROR;
352 }
353 }
346 sc->buffer = ((flags & NGX_SSL_BUFFER) != 0);
354347
355348 sc->connection = SSL_new(ssl->ctx);
356349
803796 limit = NGX_MAX_UINT32_VALUE - ngx_pagesize;
804797 }
805798
806
807799 buf = c->ssl->buf;
800
801 if (buf == NULL) {
802 buf = ngx_create_temp_buf(c->pool, NGX_SSL_BUFSIZE);
803 if (buf == NULL) {
804 return NGX_CHAIN_ERROR;
805 }
806
807 c->ssl->buf = buf;
808 }
809
810 if (buf->start == NULL) {
811 buf->start = ngx_palloc(c->pool, NGX_SSL_BUFSIZE);
812 if (buf->start == NULL) {
813 return NGX_CHAIN_ERROR;
814 }
815
816 buf->pos = buf->start;
817 buf->last = buf->start;
818 buf->end = buf->start + NGX_SSL_BUFSIZE;
819 }
820
808821 send = 0;
809822 flush = (in == NULL) ? 1 : 0;
810823
976989 c = rev->data;
977990
978991 c->write->handler(c->write);
992 }
993
994
995 void
996 ngx_ssl_free_buffer(ngx_connection_t *c)
997 {
998 if (ngx_pfree(c->pool, c->ssl->buf->start) == NGX_OK) {
999 c->ssl->buf->start = NULL;
1000 }
9791001 }
9801002
9811003
131131 ssize_t ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl);
132132 ngx_chain_t *ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in,
133133 off_t limit);
134 void ngx_ssl_free_buffer(ngx_connection_t *c);
134135 ngx_int_t ngx_ssl_shutdown(ngx_connection_t *c);
135136 void ngx_cdecl ngx_ssl_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
136137 char *fmt, ...);
21112111 hc->nbusy = 0;
21122112 }
21132113
2114 #if (NGX_HTTP_SSL)
2115 if (c->ssl) {
2116 ngx_ssl_free_buffer(c);
2117 }
2118 #endif
2119
21142120 rev->handler = ngx_http_keepalive_handler;
21152121
21162122 if (wev->active && (ngx_event_flags & NGX_USE_LEVEL_EVENT)) {