You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Michal Szymaniak <ms...@mimuw.edu.pl> on 2001/11/27 11:08:06 UTC

support for multiple tcp/udp ports

Hello,

One question about the support for udp in Apache 2.0. Is it now
possible to make A. listen on multiple tcp and udp ports, and then
call appropriate hooks for each incoming connection/datagram?

Especially, is such functionality available for module? Or there
are Apache internals that should be modified to achieve this?

Kind regards,
--
: Michal Szymaniak | mailto:mszyman@mimuw.edu.pl


Re: support for multiple tcp/udp ports

Posted by Ryan Bloom <rb...@covalent.net>.
On Friday 30 November 2001 04:19 am, Michal Szymaniak wrote:
> Hi,
>
> > If you look at the worker MPM, you will see that it actually adds a pipe
> > to the listen_rec list, but it doesn't use a hook to do it.  Can you
> > modify your code to use the pre_mpm hook, and let me know if that works? 
> > Even if it does, we may need a new hook, because the pre_mpm hook doesn't
> > get called for graceful restarts.
>
> I am not sure whether I understand how apache hooks are implemented,
> After I looked at the only function using 'ap_hook_pre_mpm',
> ap_create_scoreboard, it seems that my handler also should take one pool
> and one mysterious scoreboard switch as parameters. Don't you think
> that it is a bit too little? I really miss the module configuration
> or server_rec structure. Obviously, the former can be stored somewhere
> on module-global structures (and copied there by post_config hook),
> but I still could not find a way to get to server_rec (can I do the same,
> as for module config? is the server_rec alive through all the time
> the apache works?) . Generally, all ap_hook_pre_mpm looks like it
> was created only for managing scoreboard (it is not even documented
> elsewhere).
>
> Because of above problems, I didn't yet checked whether pre_mpm will do
> the job. But if the interface for ap_hook_pre_mpm is as described above,
> it doesn't seem to be very convenient..

Okay, I'll add an add_listener hook this weekend.

Ryan

______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------

Re: support for multiple tcp/udp ports

Posted by Michal Szymaniak <ms...@mimuw.edu.pl>.
Hi, 

> If you look at the worker MPM, you will see that it actually adds a pipe
> to the listen_rec list, but it doesn't use a hook to do it.  Can you modify 
> your code to use the pre_mpm hook, and let me know if that works?  Even
> if it does, we may need a new hook, because the pre_mpm hook doesn't
> get called for graceful restarts.

I am not sure whether I understand how apache hooks are implemented,
After I looked at the only function using 'ap_hook_pre_mpm', 
ap_create_scoreboard, it seems that my handler also should take one pool
and one mysterious scoreboard switch as parameters. Don't you think
that it is a bit too little? I really miss the module configuration
or server_rec structure. Obviously, the former can be stored somewhere
on module-global structures (and copied there by post_config hook),
but I still could not find a way to get to server_rec (can I do the same,
as for module config? is the server_rec alive through all the time
the apache works?) . Generally, all ap_hook_pre_mpm looks like it
was created only for managing scoreboard (it is not even documented
elsewhere).

Because of above problems, I didn't yet checked whether pre_mpm will do
the job. But if the interface for ap_hook_pre_mpm is as described above,
it doesn't seem to be very convenient..

Kind regards,
--
+------------------------ ---- -- -- -  -     -   
: Michal Szymaniak | mailto:mszyman@mimuw.edu.pl
.


Re: support for multiple tcp/udp ports

Posted by Ryan Bloom <rb...@covalent.net>.
On Thursday 29 November 2001 12:12 pm, Michal Szymaniak wrote:
> Hello again.
>
> > It is now possible to write a module that will make Apache listen on
> > UDP ports.  However, as somebody who has done this in the past,
> > it's not a good idea.  You lose too much data on every request.
>
> Could you explain what you mean by saying 'you lose data'? Is it losing
> data because of lack of reliability in udp, or missing datagrams that
> arrive to your udp socket and are subsequently overwritten by next ones
> before you manage to service them?

I am assuming it was because of the reliability of udp, but we ran out of time
on the project before we figured out exactly what was happening, and I
never got back to it.

> Anyway, I have tried to modify the echo module to manage additonal
> sockets: I added post_config hook that created new sockets together
> with associated apr_listen_rec structures and then simply inserted them
> into the 'ap_listeners' list. As long as the sockets were tcp-oriented,
> everything was just fine. However, after switching from SOCK_STREAM to
> SOCK_DGRAM, apache exited with a critical error, leaving (in 'error_log')
> a few lines about 'invalid operations on non-tcp socket'.

You are adding the sockets too early.  There are two ways to handle this.

1)  Use the pre_mpm hook instead of post_config.
2)  We need a new hook

If you look at the worker MPM, you will see that it actually adds a pipe
to the listen_rec list, but it doesn't use a hook to do it.  Can you modify 
your code to use the pre_mpm hook, and let me know if that works?  Even
if it does, we may need a new hook, because the pre_mpm hook doesn't
get called for graceful restarts.

Ryan
______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------

Re: support for multiple tcp/udp ports

Posted by Michal Szymaniak <ms...@mimuw.edu.pl>.

Hello again.

> It is now possible to write a module that will make Apache listen on
> UDP ports.  However, as somebody who has done this in the past,
> it's not a good idea.  You lose too much data on every request.

Could you explain what you mean by saying 'you lose data'? Is it losing
data because of lack of reliability in udp, or missing datagrams that
arrive to your udp socket and are subsequently overwritten by next ones
before you manage to service them?

Anyway, I have tried to modify the echo module to manage additonal
sockets: I added post_config hook that created new sockets together
with associated apr_listen_rec structures and then simply inserted them
into the 'ap_listeners' list. As long as the sockets were tcp-oriented,
everything was just fine. However, after switching from SOCK_STREAM to
SOCK_DGRAM, apache exited with a critical error, leaving (in 'error_log')
a few lines about 'invalid operations on non-tcp socket'.

I looked into apache source and it is clearly visible that all(?) the
routines assume the sockets from the 'ap_listeners' list to be tcp ones.
So how can I handle incoming udp datagrams _without_ modifying apache
source? BTW, the aim is not to run http over udp, but simply to support
certain stupid protocol using udp - and it will be good enough if my
module reacts for every incoming udp datagram with sending an appropriate
response in another udp datagram.

If it makes any difference - I play with apache 2.0.28.

Kind regards,
--
+------------------------ ---- -- -- -  -     -   
: Michal Szymaniak | mailto:mszyman@mimuw.edu.pl
.


Re: support for multiple tcp/udp ports

Posted by Ryan Bloom <rb...@covalent.net>.
On Tuesday 27 November 2001 02:08 am, Michal Szymaniak wrote:
> Hello,
>
> One question about the support for udp in Apache 2.0. Is it now
> possible to make A. listen on multiple tcp and udp ports, and then
> call appropriate hooks for each incoming connection/datagram?
>
> Especially, is such functionality available for module? Or there
> are Apache internals that should be modified to achieve this?

It is now possible to write a module that will make Apache listen on
UDP ports.  However, as somebody who has done this in the past,
it's not a good idea.  You lose too much data on every request.

Ryan

______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------