Welcome! Log In Create A New Profile

Advanced

Re: help with issue related to ngx_peer_connection_t, and ngx_unix_recv() returning NGX_AGAIN

Maxim Dounin
August 16, 2013 10:00PM
Hello!

On Thu, Aug 15, 2013 at 11:25:24PM +0200, Abbot, Drew wrote:

[...]

> That approach seemed ok at first, but I've been noticing strange
> behavior on the non-blocking sockets within my_read_handler().
> In particular, I call ngx_unix_recv() in my_read_handler() to
> actually receive data, but in any given invocation of
> my_read_handler(), the first call to ngx_unix_recv() never ends
> up reading more than 128 bytes, and the second call always

As your followup message suggests, 128 bytes is probably due to
socket buffer sizes you use.

> returns NGX_AGAIN, as if no more data were available at that
> time. However, I know more data is available! For example, if
> I continue to call ngx_unix_recv() is a loop, ngx_unix_recv()
> will return NGX_AGAIN forever, even though more data will
> definitely be available! It's not until a separate invocation

First of all, you shouldn't call ngx_unix_recv() directly - you
should call c->recv() instead.

Second, you are not expected to call c->recv() again after it
returns NGX_AGAIN - you should call ngx_handle_read_event()
instead, and wait for a read handler to be called again.

If a call returns NGX_AGAIN, nginx in some cases will just return
NGX_AGAIN on subsequent calls, without an actual recv() syscall -
in particular, this happens with kqueue event method where number
of bytes available is reported by kevent(). See
src/os/unix/ngx_recv.c for details.

--
Maxim Dounin
http://nginx.org/en/donation.html

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

help with issue related to ngx_peer_connection_t, and ngx_unix_recv() returning NGX_AGAIN

Abbot, Drew 911 August 15, 2013 05:26PM

RE: help with issue related to ngx_peer_connection_t, and ngx_unix_recv() returning NGX_AGAIN

Abbot, Drew 698 August 16, 2013 11:58AM

Re: help with issue related to ngx_peer_connection_t, and ngx_unix_recv() returning NGX_AGAIN

Maxim Dounin 414 August 16, 2013 10:00PM



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

Online Users

Guests: 151
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