|
Conrad Steenberg
conrad at hep.caltech.edu
Sat Nov 9 14:37:02 EST 2002
Aarghh, take 2 on the patch:
--- src/requestobject.c.orig Tue Jun 4 15:52:45 2002
+++ src/requestobject.c Tue Jun 4 11:15:49 2002
@@ -781,6 +781,27 @@
}
+/**
+ ** request.get_fd(request self)
+ **
+ * Returns the file descriptor to write output to
+ */
+
+static PyObject * req_fd(requestobject *self, PyObject *args)
+{
+ PyObject *fd;
+ long thefd;
+ thefd=(long)self->request_rec->connection->client->fd;
+ fd = PyInt_FromLong(thefd);
+ if (!fd) {
+ PyErr_SetString(PyExc_IOError, "Could not determine file descriptor.");
+ return NULL;
+ }
+
+
+ return fd;
+}
+
+
static PyMethodDef requestobjectmethods[] = {
{"add_common_vars", (PyCFunction) req_add_common_vars, METH_VARARGS},
{"add_handler", (PyCFunction) req_add_handler, METH_VARARGS},
@@ -797,6 +818,7 @@
{"register_cleanup", (PyCFunction) req_register_cleanup, METH_VARARGS},
{"send_http_header", (PyCFunction) req_send_http_header, METH_VARARGS},
{"write", (PyCFunction) req_write, METH_VARARGS},
+ {"get_fd", (PyCFunction) req_fd, METH_VARARGS},
{ NULL, NULL } /* sentinel */
};
On Sat, 2002-11-09 at 14:17, Conrad Steenberg wrote:
> Hi Mike
>
> Have a look at sendfilemodule.c in
> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/clarens/clarens/sendfile/
>
> The patch for mod_python to get the filedescriptor to write to is below.
>
> Cheers!
>
> Conrad
>
> On Fri, 2002-11-08 at 21:20, mike at mikebell.org wrote:
> > On Fri, Nov 08, 2002 at 11:24:56AM -0800, Conrad Steenberg wrote:
> > > So the question is, is anybody else interested in this? Either for me to
> > > contribute the mod_python patch and sendfile package, or for integration
> > > of these two parts into mod_pyhton itself?
> >
> > I would absolutely be interested. Zero-copy from mod_python, yay. I have
> > in fact thought about this in the past but never got around to doing
> > anything about it.
> --- src/requestobject.c.orig Tue Jun 4 15:52:45 2002
> +++ src/requestobject.c Tue Jun 4 11:15:49 2002
> @@ -781,6 +781,27 @@
>
> }
>
> +/**
> + ** request.get_fd(request self)
> + **
> + * Returns the file descriptor to write output to
> + */
> +
> +static PyObject * req_fd(requestobject *self, PyObject *args)
> +{
> + PyObject *fd;
> + long thefd;
> + thefd=(long)self->request_rec->connection->client->fd;
> + fd = PyInt_FromLong(thefd);
> + if (!fd) {
> + PyErr_SetString(PyExc_IOError, "Could not determine file descriptor.");
> + return NULL;
> + }
> +
> static PyMethodDef requestobjectmethods[] = {
> {"add_common_vars", (PyCFunction) req_add_common_vars, METH_VARA
> {"add_handler", (PyCFunction) req_add_handler, METH_VARA
> @@ -797,6 +818,7 @@
> {"register_cleanup", (PyCFunction) req_register_cleanup, METH_VARA
> {"send_http_header", (PyCFunction) req_send_http_header, METH_VARA
> {"write", (PyCFunction) req_write, METH_VARA
> + {"get_fd", (PyCFunction) req_fd, METH_VARA
> { NULL, NULL } /* sentinel */
> };
>
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python
|