create ssl buffer on demand and free it before keep-alive
Igor Sysoev
14 years ago
343 | 343 |
return NGX_ERROR;
|
344 | 344 |
}
|
345 | 345 |
|
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);
|
354 | 347 |
|
355 | 348 |
sc->connection = SSL_new(ssl->ctx);
|
356 | 349 |
|
|
803 | 796 |
limit = NGX_MAX_UINT32_VALUE - ngx_pagesize;
|
804 | 797 |
}
|
805 | 798 |
|
806 | |
|
807 | 799 |
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 |
|
808 | 821 |
send = 0;
|
809 | 822 |
flush = (in == NULL) ? 1 : 0;
|
810 | 823 |
|
|
976 | 989 |
c = rev->data;
|
977 | 990 |
|
978 | 991 |
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 |
}
|
979 | 1001 |
}
|
980 | 1002 |
|
981 | 1003 |
|
131 | 131 |
ssize_t ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl);
|
132 | 132 |
ngx_chain_t *ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in,
|
133 | 133 |
off_t limit);
|
|
134 |
void ngx_ssl_free_buffer(ngx_connection_t *c);
|
134 | 135 |
ngx_int_t ngx_ssl_shutdown(ngx_connection_t *c);
|
135 | 136 |
void ngx_cdecl ngx_ssl_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
|
136 | 137 |
char *fmt, ...);
|