On 16/01/18 18:13, Jesus Cea wrote: > Thanks for your time, Graham. Much appreciated.
Reading source code, I see things I don't understand and could be the issue:
When a request is processed, if it preemptively marked as "error 500".
This code will be changed to the right result code when the request
finishs. This is a good approach, because any oversight will be shown as
"error 500". Good so far.
File "mod_wsgi.c", line 3175.
"Adapter_output" will return "0" if the client closed the connection. In
that case, source code set "aborted=1". Cool.
A few lines later we have this:
"""
if (!PyErr_Occurred() && !aborted) {
if (Adapter_output(self, "", 0, NULL, 0))
self->result = OK;
}
"""
I am not sure why "Adapter_output()" is called with NOOP operation
(maybe to signal "end of stream", but then I don't know why it is only
done when no python error occurred), but "self->result=OK" requires
"aborted==0". This is not going to happen if we have "aborted==1".
I think that if we have "abort != 0" and "!PyErr_Occurred()", we should
do "self->result = OK;" unconditionally.
Maybe better something like this:
if(!PyErr_Occurred()) {
if(aborted) {
self->result = OK;
} else {
if (Adapter_output(self, "", 0, NULL, 0))
self->result = OK;
}
}
Or even:
if(!PyErr_Occurred()) {
if(!aborted)
Adapter_output(self, "", 0, NULL, 0);
self->result = OK;
}
Or even:
if(!aborted)
Adapter_output(self, "", 0, NULL, 0); // ?? Signal end of string???
if(!PyErr_Occurred())
self->result = OK;
A while later we will log an error (at debug level, you usually don't
see it) if data length we send is not the same than the "content-length"
header. That would be a mistake if "aborted==1". In that case we should
ONLY log an error if "content-length>actual data length sent".
This is only code inspection, without knowing about mod_wsgi internals.
I didn't even try to compile. What do you think, Graham?.
Apparently this takes care of the "embedded mode". Didn't check, really.
Reading more source code, I find "wsgi_transfer_response", returning 500
for almost everything that. I changed there all "return
HTTP_INTERNAL_SERVER_ERROR;" to:
"""
if (r->connection->aborted)
return OK;
else
return HTTP_INTERNAL_SERVER_ERROR;
"""
This seems to get rid of the problem!. Now I have "200" and "206" in my
server log! :).
I didn't take care of logging details, specially the "content-length"
mismatch described before in this text.
Do you agree with this patch?. Do you want a pull request in github?.
PS: I have been testing these changes in last couple of hours.
Everything seems good so far.
--
Jesús Cea Avión _/_/ _/_/_/ _/_/_/
[email protected] - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/
Twitter: @jcea _/_/ _/_/ _/_/_/_/_/
jabber / xmpp:[email protected] _/_/ _/_/ _/_/ _/_/ _/_/
"Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/
"My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: OpenPGP digital signature
