Skip to content

Commit

Permalink
(MODPYTHON-180) Publisher would wrongly output a warning about nothin…
Browse files Browse the repository at this point in the history
…g to

publish if req.write() or req.sendfile() used and data not flushed, and
then published function returned None.
  • Loading branch information
grahamd committed Oct 8, 2006
1 parent eab1bcb commit 84620f8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Doc/appendixc.tex
Expand Up @@ -349,6 +349,11 @@ \chapter{Changes from Version (3.2.x)\label{app-changes-from-3.2.x}}
(\citetitle[http://issues.apache.org/jira/browse/MODPYTHON-179]{MODPYTHON-179})
Fixed the behaviour of req.readlines() when a size hint was provided. Previously,
it would always return a single line when a size hint was provided.
\item
(\citetitle[http://issues.apache.org/jira/browse/MODPYTHON-180]{MODPYTHON-180})
Publisher would wrongly output a warning about nothing to publish if
\code{req.write()} or \code{req.sendfile()} used and data not flushed,
and then published function returned \code{None}.
\item
(\citetitle[http://issues.apache.org/jira/browse/MODPYTHON-181]{MODPYTHON-181})
Fixed memory leak when mod_python handlers are defined for more than
Expand Down
2 changes: 1 addition & 1 deletion lib/python/mod_python/__init__.py
Expand Up @@ -20,5 +20,5 @@
__all__ = ["apache", "cgihandler", "psp",
"publisher", "util", "python22"]

version = "3.3.0-dev-20060827"
version = "3.3.0-dev-20061008"

2 changes: 1 addition & 1 deletion lib/python/mod_python/publisher.py
Expand Up @@ -213,7 +213,7 @@ def handler(req):
published = publish_object(req, object)

# we log a message if nothing was published, it helps with debugging
if (not published) and (req.bytes_sent==0) and (req.next is None):
if (not published) and (req._bytes_queued==0) and (req.next is None):
log=int(req.get_config().get("PythonDebug", 0))
if log:
req.log_error("mod_python.publisher: nothing to publish.")
Expand Down
4 changes: 2 additions & 2 deletions src/include/mpversion.h
@@ -1,5 +1,5 @@
#define MPV_MAJOR 3
#define MPV_MINOR 3
#define MPV_PATCH 0
#define MPV_BUILD 20061002
#define MPV_STRING "3.3.0-dev-20061002"
#define MPV_BUILD 20061008
#define MPV_STRING "3.3.0-dev-20061008"
1 change: 1 addition & 0 deletions src/include/requestobject.h
Expand Up @@ -42,6 +42,7 @@ extern "C" {
PyObject * phase;
char * extension; /* for | .ext syntax */
int content_type_set;
apr_off_t bytes_queued;
hlistobject * hlo;
PyObject * callbacks;
char * rbuff; /* read bufer */
Expand Down
17 changes: 17 additions & 0 deletions src/requestobject.c
Expand Up @@ -67,6 +67,7 @@ PyObject * MpRequest_FromRequest(request_rec *req)
result->phase = NULL;
result->extension = NULL;
result->content_type_set = 0;
result->bytes_queued = 0;
result->hlo = NULL;
result->callbacks = PyList_New(0);
if (!result->callbacks)
Expand Down Expand Up @@ -1462,6 +1463,8 @@ static PyObject * req_write(requestobject *self, PyObject *args)
}
}

self->bytes_queued += len;

Py_INCREF(Py_None);
return Py_None;

Expand Down Expand Up @@ -1538,6 +1541,8 @@ static PyObject * req_sendfile(requestobject *self, PyObject *args)
return NULL;
}

self->bytes_queued += len;

py_result = PyLong_FromLong (nbytes);
Py_INCREF(py_result);
return py_result;
Expand Down Expand Up @@ -1692,6 +1697,17 @@ static PyObject *getreq_recmbr(requestobject *self, void *name)
Py_INCREF(self->notes);
return self->notes;
}
else if (strcmp(name, "_bytes_queued") == 0) {
if (sizeof(apr_off_t) == sizeof(LONG_LONG)) {
LONG_LONG l = self->bytes_queued;
return PyLong_FromLongLong(l);
}
else {
/* assume it's long */
long l = self->bytes_queued;
return PyLong_FromLong(l);
}
}
else
return PyMember_GetOne((char*)self->request_rec,
find_memberdef(request_rec_mbrs, name));
Expand Down Expand Up @@ -2006,6 +2022,7 @@ static PyGetSetDef request_getsets[] = {
/* XXX htaccess */
/* XXX filters and eos */
{"eos_sent", (getter)getreq_recmbr, NULL, "EOS bucket sent", "eos_sent"},
{"_bytes_queued", (getter)getreq_recmbr, NULL, "Bytes queued by handler", "_bytes_queued"},
{NULL} /* Sentinel */
};

Expand Down

0 comments on commit 84620f8

Please sign in to comment.