Improve iterator support for Python req.response().

If the connection on which we are about to send the response was
marked as disconnecting, do not go ahead and hook into the disconnect
callback (it will never be called, it is already disconnecting).

Instead just return, the connection will be removed anyway.
This commit is contained in:
Joris Vink 2019-06-05 10:35:47 +02:00
parent 93b1d621d7
commit 89e58fa474
1 changed files with 5 additions and 2 deletions

View File

@ -3159,11 +3159,14 @@ pyhttp_response(struct pyhttp_request *pyreq, PyObject *args)
} else if (obj == Py_None) {
http_response(pyreq->req, status, NULL, 0);
} else {
c = pyreq->req->owner;
if (c->state == CONN_STATE_DISCONNECTING) {
Py_RETURN_FALSE;
}
if ((iterator = PyObject_GetIter(obj)) == NULL)
return (NULL);
c = pyreq->req->owner;
iterobj = kore_pool_get(&iterobj_pool);
iterobj->iterator = iterator;
iterobj->connection = c;