diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2004-07-14 16:01:42 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2004-07-14 16:01:42 +0000 |
| commit | 7823cc3b0d263530ed4590d27ee4d1fe12dca0dc (patch) | |
| tree | deefa1b73d160085ae87c6f887298c8b95051e6b /src/http/modules | |
| parent | 846c27b2acc5f6bf942bab0d8c3b5e653b9513b4 (diff) | |
| download | nginx-7823cc3b0d263530ed4590d27ee4d1fe12dca0dc.tar.gz nginx-7823cc3b0d263530ed4590d27ee4d1fe12dca0dc.tar.bz2 | |
nginx-0.0.7-2004-07-14-20:01:42 import
Diffstat (limited to 'src/http/modules')
| -rw-r--r-- | src/http/modules/ngx_http_ssl_filter.c | 48 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_ssl_filter.h | 2 |
2 files changed, 42 insertions, 8 deletions
diff --git a/src/http/modules/ngx_http_ssl_filter.c b/src/http/modules/ngx_http_ssl_filter.c index 742c29366..344577b64 100644 --- a/src/http/modules/ngx_http_ssl_filter.c +++ b/src/http/modules/ngx_http_ssl_filter.c @@ -22,12 +22,12 @@ typedef struct { typedef struct { SSL *ssl; - - unsigned accepted; } ngx_http_ssl_ctx_t; static ngx_http_ssl_ctx_t *ngx_http_ssl_create_ctx(ngx_http_request_t *r); +static ngx_chain_t *ngx_http_ssl_write(ngx_http_request_t *r, ngx_chain_t *in, + off_t limit); static void ngx_http_ssl_error(ngx_uint_t level, ngx_log_t *log, int err, char *fmt, ...); static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf); @@ -152,7 +152,7 @@ ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t n) } ngx_http_ssl_error(NGX_LOG_ALERT, r->connection->log, rc, - "SSL_accept() failed"); + "SSL_read() failed"); SSL_set_shutdown(ctx->ssl, SSL_RECEIVED_SHUTDOWN); @@ -160,11 +160,8 @@ ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t n) } -ngx_int_t ngx_http_ssl_write(ngx_http_request_t *r, ngx_chain_t *in, - off_t limit) +ngx_int_t ngx_http_ssl_writer(ngx_http_request_t *r, ngx_chain_t *in) { - int rc; - size_t send, size; ngx_http_ssl_ctx_t *ctx; ctx = ngx_http_get_module_ctx(r, ngx_http_ssl_filter_module); @@ -175,7 +172,12 @@ ngx_int_t ngx_http_ssl_write(ngx_http_request_t *r, ngx_chain_t *in, ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "SSL_shutdown: %d", rc); + if (rc == 0) { + return NGX_AGAIN; + } + if (rc == 1) { + SSL_free(ctx->ssl); return NGX_OK; } @@ -188,9 +190,28 @@ ngx_int_t ngx_http_ssl_write(ngx_http_request_t *r, ngx_chain_t *in, return NGX_AGAIN; } + ngx_http_ssl_error(NGX_LOG_ALERT, r->connection->log, rc, + "SSL_shutdown() failed"); + return NGX_ERROR; } + ch = ngx_http_ssl_write(r, ctx, in, 0); + + return NGX_OK; +} + + +static ngx_chain_t *ngx_http_ssl_write(ngx_http_request_t *r, + ngx_http_ssl_ctx_t *ctx, + ngx_chain_t *in, + off_t limit) +{ + int rc; + size_t send, size; + + ctx = ngx_http_get_module_ctx(r, ngx_http_ssl_filter_module); + send = 0; for (/* void */; in; in = in->next) { @@ -205,9 +226,20 @@ ngx_int_t ngx_http_ssl_write(ngx_http_request_t *r, ngx_chain_t *in, } rc = SSL_write(ctx->ssl, in->buf->pos, size); + + if (rc > 0) { + in->buf->pos += rc; + + if (rc == size) { + continue; + } + + r->connection->write->ready = 0; + return in; + } } - return NGX_OK; + return in; } diff --git a/src/http/modules/ngx_http_ssl_filter.h b/src/http/modules/ngx_http_ssl_filter.h index b94b36724..9bbe65a4f 100644 --- a/src/http/modules/ngx_http_ssl_filter.h +++ b/src/http/modules/ngx_http_ssl_filter.h @@ -14,6 +14,8 @@ ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t n); +ngx_int_t ngx_http_ssl_writer(ngx_http_request_t *r, ngx_chain_t *in); + void ngx_http_ssl_close_connection(SSL *ssl, ngx_log_t *log); |
