Welcome! Log In Create A New Profile

Advanced

Re: Patch for test reading function

Maxim Dounin
October 01, 2011 07:12AM
Hello!

On Sat, Oct 01, 2011 at 12:52:37AM -0300, Wandenberg Peixoto wrote:

> Hi,
>
> I would like to suggest a small patch for function ngx_http_test_reading to
> properly works under https connections.
> Using SSL_peek function to detect when request is ended by the client.
>
> I hope you accept it.
>
> Regards,
> Wandenberg

> --- src/http/ngx_http_request.c 2011-10-01 00:27:17.895845001 -0300
> +++ src/http/ngx_http_request.c 2011-10-01 00:15:46.055845002 -0300
> @@ -2353,7 +2353,15 @@
>
> #endif
>
> +#if (NGX_HTTP_SSL)
> + if (c->ssl != NULL) {
> + n = SSL_peek(c->ssl->connection, buf, 1);
> + } else {
> + n = recv(c->fd, buf, 1, MSG_PEEK);
> + }
> +#else
> n = recv(c->fd, buf, 1, MSG_PEEK);
> +#endif
>
> if (n == 0) {
> rev->eof = 1;
> @@ -2363,9 +2371,19 @@
> goto closed;
>
> } else if (n == -1) {
> - err = ngx_socket_errno;
> +#if (NGX_HTTP_SSL)
> + if (c->ssl != NULL) {
> + err = SSL_get_error(c->ssl->connection, n);
> + } else {
> + err = ngx_socket_errno;
> + }
> +
> + if ((err != NGX_EAGAIN) && (err != SSL_ERROR_WANT_READ) && (err != SSL_ERROR_WANT_WRITE)) {
> +#else
> + err = ngx_socket_errno;
>
> - if (err != NGX_EAGAIN) {
> + if (err != NGX_EAGAIN) {
> +#endif
> rev->eof = 1;
> c->error = 1;
>

(Just a side note: there are multiple style issues in the patch.)

I would like to see this abstracted in connection API, with
something like c->peek() (handled by ssl events code for ssl
connections, much like it's currently done for c->recv()).

Maxim Dounin

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Patch for test reading function

wandenberg 1856 October 01, 2011 12:00AM

Re: Patch for test reading function

Maxim Dounin 714 October 01, 2011 07:12AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 188
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready