You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Issac Goldstand <ma...@beamartyr.net> on 2007/09/05 12:07:33 UTC

[patch] experimental UDP support in httpd-prefork/apr/apr-util trunk

After taking my own advice on Sunday, I reworked everything I'd done for
UDP support and focused on allowing the core I/O filters to work with
non-connected sockets.  I'm happy to report that I've come up with a
working prototype for prefork that fully supports UDP and doesn't
require substantial amounts of mucking with the MPM code (so it will
hopefully be fairly simple to patch the other MPMs).  It requires
patches to APR (to add a apr_socket_sendtov function, needed by the core
output filter) and APR-Util to support apr_socket_readfrom in socket
buckets that aren't connected).  Both of these patches would be useful
in APR/APR-Util regardles (although the APR patch still requires work
for win32, beos and netware - I suppose I'll tackle at least win32
[which I'm familiar with] later today and we'll see about the others).
As such, I've added these both to bugzilla to
https://issues.apache.org/bugzilla/show_bug.cgi?id=43309 and
https://issues.apache.org/bugzilla/show_bug.cgi?id=43302, respectively
(thus the CC to dev@apr).

To go through what I've done in the main patch (for those who want an
idea of what they're looking at):

* Export ap_alloc_listner and take socket type/protocol as arguments
* In core_create_conn, if the remote_addr of the socket can't be
detected from the socket, try to run recvfrom in PEEK mode to get the
peer address
* Core input filters run as-is (patch to apr-util does everything)
* Core output filter tries (in init) to see if socket is connected.  If
not, it turns of a new flag, connected, in ctx which is ultimately used
to decide whether to pass data to apr_socket_sendv or apr_socket_sendtov
* Additionally, disable SENDFILE for non-stream sockets
* Create ListenUDP config directive to create UDP listeners
* Alter all MPMs to only call lr->accept_func if it's defined
* In prefork, re-create the pollset in every iteration of child_main and
include that in the mutex.  Hack the use of lr->active to add a flag
(value 2) for in-use UDP sockets (and don't add them to the pollset if
they're found).  Don't connect UDP sockets and don't close them after
the connection is finished - just re-allow the socket to be polled
* Don't try to disable nagle on non-TCP sockets
* Support non-TCP dummy connections

I already have a prototype version of a DNS protocol module which has
worked for months over TCP and seems so far to work flawlessly using
this patch.  Is there any interest in adopting this to the httpd
project?  If so, I'd love to continue helping out on this.

  Issac