Checking what was happening and comparing with others calls on same file
ngx_http_request.c I saw that others calls are done with c->recv instead
of recv .
On the case of https this c->recv points to ngx_ssl_recv, which can sure
detect when user goes off.
I would like to suggest to change the line
n = recv(c->fd, buf, 1, MSG_PEEK);
for
n = c->recv(c, buf, 1);
and
} else if (n == -1) {
for
} else if ((n == -1) || (n == -2)) {
to other returns on https.
I’m not sure if it has any side effect, and don’t know if here is the
best place to do this suggestion, sorry if not.
On Sat, Jun 25, 2011 at 04:06:30PM -0400, wandenberg wrote:
Sorry Maxim. I didn’t understood your answer.
You can’t use c->recv() as it doesn’t allow to peek. Using
c->recv() will result in possibly valid and required data to be
lost. And that’s why normal recv() is used instead there.
Can you explain better? Why this work for detect when users goes off on
http, but not in https ?
Quoting just 2 days old message from the same list[1]:
% Yes, the code in question won’t be able to detect SSL connection
% close with appropriate shutdown records sent by a client (as well
% as connection close with some other pending data, e.g. pipelined
% request). It is not possible to detect connection close with
% standard socket interface if there are pending data without
% reading that data first, which isn’t always desired/possible.
%
% In the particular case of SSL it should be possible to use
% SSL_peek() here, but better aproach is to use OS-provided hint,
% e.g. as EV_EOF provided by kqueue interface (and used by nginx).
Thanks for your explanation.
Now I understood, sorry for my mistakes.
Maxim D. Wrote:
required data to be
lost. And that’s why normal recv() is used
instead there.
I turned back to use normal recv() respecting msg_peek functionality.
a client (as well
possible to use
% SSL_peek() here, but better aproach is to use
OS-provided hint,
% e.g. as EV_EOF provided by kqueue interface (and
used by nginx).