You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Michael <co...@uhome.net> on 2002/12/27 18:51:55 UTC
[mp2] APR::Socket::recv set read timeout ?
Hi all.
As suggested by Geoff and Stas, I am trying out modperl2.. Now I have some questions:
i) with Apache::CommandServer (can be found at http://perl.apache.org/docs/2.0/user/overview/overview.html#toc_Protocol_Modules_with_mod_perl_2_0), I setup everything according to the guide..but
> telnet localhost 8084
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
Login: foo
Password: foo
^]
I must hit return once before the 'Login' prompt appears, and after a few tests I found that $socket->send() do not send the buffer to the client right away. Is this related to some configurable directives in httpd.conf or I did something wrong.. or just a feature?
ii) is there any way to perform a select(2) or like on the $socket? I would like to implement some sort of 'timeout' in the read loop..say, after 5 secs if nothing is recv'd from the client then the connection will be closed. I have tried alarm/die pair but it was a failure. Any idea?
Thanks in advance.
Michael
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Stas Bekman <st...@stason.org>.
Michael wrote:
>>>ii) is there any way to perform a select(2) or like on the $socket? I
>>>would like to implement some sort of 'timeout' in the read loop..say,
>>>after 5 secs if nothing is recv'd from the client then the connection
>>>will be closed. I have tried alarm/die pair but it was a failure. Any
>>
> idea?
>
>>You have the APR::Socket object, so it should be possible. Though I see
>>that apr_poll_ API is not glued.
>>
>>!MODULE=APR::Poll
>> apr_poll_socket_add
>> apr_poll_socket_clear
>> apr_poll_data_get
>> apr_poll_revents_get
>> apr_poll_socket_mask
>> apr_poll
>> apr_poll_socket_remove
>> apr_poll_data_set
>> apr_poll_setup
>>
>>The ! mark in xs/maps/apr_functions.map disables the glueing of this API
>>subset at the build time.
>
>
> sorry but I would like to ask how do I glue that?
> I tried the util/xs_check.pl in the modperl2 src dir, and it reports..
>
> unable to glue 27 mapped functions:
[...]
it requires more than that, since the C types used by apr_pool functions
aren't all having Perl typemap entries. Before we implement these let's
ask Doug why he chose to skip APR::Poll in first place.
> Finally, as I've mention before, I would like to put this non http thing
> together with other http things on the same port 80. Is this possible? say,
> when this handler sees GET|POST|HEAD it forgets the request and let the
> Apache HTTP module process it in the normal way?
This is a job of the PerlPreConnectionHandler, which is currently not
implemented. Its purpose is to look at the first request of the new
connection and dynamically assign a protocol handler for the current
connection.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 31 Dec 2002, Stas Bekman wrote:
> Do you have a pointer to the thread you are talking about?
no, but there are several. the thread on removal of client_socket from
conn_rec likely has some good details.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:
> On Mon, 30 Dec 2002, Stas Bekman wrote:
>
>
>>Do you have an example of such a protocol handler, which uses bbs?
>
>
> no, but using filters would be the proper way. we really shouldn't even
> be exposing $r->connection->client_socket based on discussions i've seen
> on dev@httpd. we need to make connection filters easier to use in
> Perl land (the stream like interface), not expose methods to use
> client_socket directly.
Do you have a pointer to the thread you are talking about?
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Doug MacEachern <do...@covalent.net>.
On Mon, 30 Dec 2002, Stas Bekman wrote:
> Do you have an example of such a protocol handler, which uses bbs?
no, but using filters would be the proper way. we really shouldn't even
be exposing $r->connection->client_socket based on discussions i've seen
on dev@httpd. we need to make connection filters easier to use in
Perl land (the stream like interface), not expose methods to use
client_socket directly.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:
> On Mon, 30 Dec 2002, Stas Bekman wrote:
>
>
>>Yes, when protocol handlers are working directly with a connection
>>socket, filters can't be used.
>
>
> why the need to use the connection socket directly rather than via
> filters?
Because to use filters you need to work with bucket brigades, which
makes it much harder to implement interactive protocols, like in your
CommandServer example:
http://www.apache.org/~dougm/modperl_2.0.html#apache::commandserver
Do you have an example of such a protocol handler, which uses bbs?
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Doug MacEachern <do...@covalent.net>.
On Mon, 30 Dec 2002, Stas Bekman wrote:
> Yes, when protocol handlers are working directly with a connection
> socket, filters can't be used.
why the need to use the connection socket directly rather than via
filters?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:
> if you asked how to implement the same module in C on dev@httpd, they'd
> say "use filters". which handles timeout, buffering, putback, etc.
> pretty sure that's the right answer here too.
> are there some good reasons not to use filters here?
Yes, when protocol handlers are working directly with a connection
socket, filters can't be used.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Doug MacEachern <do...@covalent.net>.
if you asked how to implement the same module in C on dev@httpd, they'd
say "use filters". which handles timeout, buffering, putback, etc.
pretty sure that's the right answer here too.
are there some good reasons not to use filters here?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Stas Bekman <st...@stason.org>.
Doug, Michael asks how to poll on Apache::Socket in the protocol
handlers. It seems that APR::Poll's functions should do the work, but
it's !APR::Poll in the map file. Any reason for not having this module
enabled?
Would be nice to annotate the map files to explain why certain modules
aren't glued, to avoid drags in the future.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Michael <co...@uhome.net>.
> Michael wrote:
> > Hi all.
> >
> > As suggested by Geoff and Stas, I am trying out modperl2.. Now I have
> > some questions:
> >
> > i) with Apache::CommandServer (can be found at
> >
http://perl.apache.org/docs/2.0/user/overview/overview.html#toc_Protocol_Mod
ules_with_mod_perl_2_0),
> > I setup everything according to the guide..but
> >
> > > telnet localhost 8084
> > Trying 127.0.0.1...
> > Connected to localhost (127.0.0.1).
> > Escape character is '^]'.
> >
> > Login: foo
> > Password: foo
> > ^]
> >
> > I must hit return once before the 'Login' prompt appears, and after a
> > few tests I found that $socket->send() do not send the buffer to the
> > client right away. Is this related to some configurable directives in
> > httpd.conf or I did something wrong.. or just a feature?
>
> I'm trying to bring the overview and design notes docs up-to-date, Doug
> wrote them long time ago and things have changed a bit since then. The
> almost up-to-date version of the overview is here:
> http://perl.apache.org/docs/2.0/user/intro/overview.html
> How did you get to the old URL? Via google?
I think I found that link somewhere in the user guide, but I am not sure
anyway.
> > ii) is there any way to perform a select(2) or like on the $socket? I
> > would like to implement some sort of 'timeout' in the read loop..say,
> > after 5 secs if nothing is recv'd from the client then the connection
> > will be closed. I have tried alarm/die pair but it was a failure. Any
idea?
>
> You have the APR::Socket object, so it should be possible. Though I see
> that apr_poll_ API is not glued.
>
> !MODULE=APR::Poll
> apr_poll_socket_add
> apr_poll_socket_clear
> apr_poll_data_get
> apr_poll_revents_get
> apr_poll_socket_mask
> apr_poll
> apr_poll_socket_remove
> apr_poll_data_set
> apr_poll_setup
>
> The ! mark in xs/maps/apr_functions.map disables the glueing of this API
> subset at the build time.
sorry but I would like to ask how do I glue that?
I tried the util/xs_check.pl in the modperl2 src dir, and it reports..
unable to glue 27 mapped functions:
ap_allow_standard_methods
ap_register_input_filter
ap_register_output_filter
apr_brigade_printf
apr_brigade_puts
apr_brigade_write
apr_getnameinfo
apr_parse_addr_port
apr_poll
apr_poll_revents_get
apr_poll_setup
apr_poll_socket_add
apr_poll_socket_clear
apr_poll_socket_mask
apr_poll_socket_remove
apr_pool_child_cleanup_set
apr_pool_cleanup_kill
apr_pool_cleanup_run
apr_pool_get_abort
apr_pool_note_subprocess
apr_pool_userdata_get
apr_pool_userdata_set
apr_shutdown
apr_socket_addr_get
apr_socket_data_get
apr_socket_data_set
apr_socket_from_file
Finally, as I've mention before, I would like to put this non http thing
together with other http things on the same port 80. Is this possible? say,
when this handler sees GET|POST|HEAD it forgets the request and let the
Apache HTTP module process it in the normal way?
Re: [mp2] APR::Socket::recv set read timeout ?
Posted by Stas Bekman <st...@stason.org>.
Michael wrote:
> Hi all.
>
> As suggested by Geoff and Stas, I am trying out modperl2.. Now I have
> some questions:
>
> i) with Apache::CommandServer (can be found at
> http://perl.apache.org/docs/2.0/user/overview/overview.html#toc_Protocol_Modules_with_mod_perl_2_0),
> I setup everything according to the guide..but
>
> > telnet localhost 8084
> Trying 127.0.0.1...
> Connected to localhost (127.0.0.1).
> Escape character is '^]'.
>
> Login: foo
> Password: foo
> ^]
>
> I must hit return once before the 'Login' prompt appears, and after a
> few tests I found that $socket->send() do not send the buffer to the
> client right away. Is this related to some configurable directives in
> httpd.conf or I did something wrong.. or just a feature?
I'm trying to bring the overview and design notes docs up-to-date, Doug
wrote them long time ago and things have changed a bit since then. The
almost up-to-date version of the overview is here:
http://perl.apache.org/docs/2.0/user/intro/overview.html
How did you get to the old URL? Via google?
For the latest docs on protocols see:
http://perl.apache.org/docs/2.0/user/handlers/protocols.html
If based on this doc you can bring the example from the overview
up-to-date and send a patch here, I'll move it into the protocols doc,
where it belongs.
> ii) is there any way to perform a select(2) or like on the $socket? I
> would like to implement some sort of 'timeout' in the read loop..say,
> after 5 secs if nothing is recv'd from the client then the connection
> will be closed. I have tried alarm/die pair but it was a failure. Any idea?
You have the APR::Socket object, so it should be possible. Though I see
that apr_poll_ API is not glued.
!MODULE=APR::Poll
apr_poll_socket_add
apr_poll_socket_clear
apr_poll_data_get
apr_poll_revents_get
apr_poll_socket_mask
apr_poll
apr_poll_socket_remove
apr_poll_data_set
apr_poll_setup
The ! mark in xs/maps/apr_functions.map disables the glueing of this API
subset at the build time.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com