You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Sorin Manolache <so...@gmail.com> on 2009/08/24 09:11:43 UTC

Re: Detecting when KeepAlive connection timeouts (retrieving the browser fd)

On Mon, Aug 24, 2009 at 00:08, Alexander
Farber<al...@gmail.com> wrote:
> Hello,
>
> I have a multiplayer game with Flash clients:
>
> 1) The Flash client sends HTTP requests to the Apache module,
> 2) then the module write()s it over a Unix pipe to the game daemon,
> 3) then the Apache module read()s the daemon's response
> 4) and finally ap_rwrite()s it back to the browser.
>
> Because I want to implement a "server push",
> my game daemon doesn't write() anything back
> to the Apache module when there are no new infos,
> but blocks instead (i.e. the step 3 above blocks).
>
> When the blocking HTTP requests timeouts,
> I notice this at the Flash client and just restart it.
>
> My problem is that at the game daemon side
> I don't notice this, since the Apache module
> itself can only notice the timeout in the step 4
> (but it doesn't come sofar - it blocks in step 3).
>
> So I think I should select() or poll() on 2 fds
> in my Apache module - one is the Unix pipe
> to the game daemon and another fd should
> be the socket fd to the browser.
>
> My question is how do I retrieve the latter fd,
> so that I can select() or poll() on it?
>

Hook pre_connection(conn_rec *c, void *csd)

The csd is the abstract type apr_socket_t. This one has a field
socketdes. I think this is the descriptor you are looking for.

Please note that I base my recommendation on Apache 2.2.x (not 1.3.x)!
Also, I have not tried out the solution I'm proposing ;-).

S

> Thank you
> Alex
>
> PS: I'm using Apache 1.3.29 on OpenBSD 4.5 with
>   "KeepAlive On" and "KeepAliveTimeout 300"
>



-- 
A: Because it reverses the logical flow of conversation.
Q: Why is top-posting frowned upon?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Re: Detecting when KeepAlive connection timeouts (retrieving the browser fd)

Posted by Alexander Farber <al...@gmail.com>.
Thank you

On Tue, Aug 25, 2009 at 10:56 AM, Rainer Jung<ra...@kippdata.de> wrote:
> There is a similar hook for Apache 1.3 when compiled with mod_ssl.
> mod_ssl comes with source patches adding more hooks to Apache 1.3 (the
> so called Extended API = EAPI). The extended API has a new_connection().
>
> I didn't check the non-EAPI one, but at least with EAPI conn_rec
> contains a BUFF, that encapsulated the FDs and more.
>

Re: Detecting when KeepAlive connection timeouts (retrieving the browser fd)

Posted by Rainer Jung <ra...@kippdata.de>.
On 25.08.2009 09:05, Alexander Farber wrote:
> On Mon, Aug 24, 2009 at 9:11 AM, Sorin Manolache<so...@gmail.com> wrote:
>> On Mon, Aug 24, 2009 at 00:08, Alexander
>> Farber<al...@gmail.com> wrote:
>>>
>>> So I think I should select() or poll() on 2 fds
>>> in my Apache module - one is the Unix pipe
>>> to the game daemon and another fd should
>>> be the socket fd to the browser.
>>>
>>> My question is how do I retrieve the latter fd,
>>> so that I can select() or poll() on it?
>>>
>>
>> Hook pre_connection(conn_rec *c, void *csd)
>>
>> The csd is the abstract type apr_socket_t. This one has a field
>> socketdes. I think this is the descriptor you are looking for.
>>
>> Please note that I base my recommendation on Apache 2.2.x (not 1.3.x)!
>> Also, I have not tried out the solution I'm proposing ;-).
> 
> I keep looking and can't find it for Apache 1.3.x.
> Which one of these is it please:
> 
> module asis_module = {
> STANDARD_MODULE_STUFF,
> NULL, /* initializer */
> NULL, /* create per-directory config structure */
> NULL, /* merge per-directory config structures */
> NULL, /* create per-server config structure */
> NULL, /* merge per-server config structures */
> NULL, /* command table */
> asis_handlers, /* handlers */
> NULL, /* translate_handler */
> NULL, /* check_user_id */
> NULL, /* check auth */
> NULL, /* check access */
> NULL, /* type_checker */
> NULL, /* prerun fixups */
> NULL /* logger */
> NULL, /* header parser */
> NULL, /* child_init */
> NULL, /* child_exit */
> NULL /* post read request */
> };
> 
> Also there is no access to the browser socket from the conn_rec structure?
> 
> Regards
> Alex

There is a similar hook for Apache 1.3 when compiled with mod_ssl.
mod_ssl comes with source patches adding more hooks to Apache 1.3 (the
so called Extended API = EAPI). The extended API has a new_connection().

I didn't check the non-EAPI one, but at least with EAPI conn_rec
contains a BUFF, that encapsulated the FDs and more.

Regards,

Rainer

Re: Detecting when KeepAlive connection timeouts (retrieving the browser fd)

Posted by Alexander Farber <al...@gmail.com>.
Hello,

On Mon, Aug 24, 2009 at 9:11 AM, Sorin Manolache<so...@gmail.com> wrote:
> On Mon, Aug 24, 2009 at 00:08, Alexander
> Farber<al...@gmail.com> wrote:
>>
>> So I think I should select() or poll() on 2 fds
>> in my Apache module - one is the Unix pipe
>> to the game daemon and another fd should
>> be the socket fd to the browser.
>>
>> My question is how do I retrieve the latter fd,
>> so that I can select() or poll() on it?
>>
>
> Hook pre_connection(conn_rec *c, void *csd)
>
> The csd is the abstract type apr_socket_t. This one has a field
> socketdes. I think this is the descriptor you are looking for.
>
> Please note that I base my recommendation on Apache 2.2.x (not 1.3.x)!
> Also, I have not tried out the solution I'm proposing ;-).

I keep looking and can't find it for Apache 1.3.x.
Which one of these is it please:

module asis_module = {
STANDARD_MODULE_STUFF,
NULL, /* initializer */
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
NULL, /* command table */
asis_handlers, /* handlers */
NULL, /* translate_handler */
NULL, /* check_user_id */
NULL, /* check auth */
NULL, /* check access */
NULL, /* type_checker */
NULL, /* prerun fixups */
NULL /* logger */
NULL, /* header parser */
NULL, /* child_init */
NULL, /* child_exit */
NULL /* post read request */
};

Also there is no access to the browser socket from the conn_rec structure?

Regards
Alex