On 2012-06-04 18:40, Robert Mitschke wrote:
Hi everybody,

I am attempting to write a module that implements a binary protocol that is
not http and is not fully request and response based using apache. I have
looked at mode echo and some others and I have Nick Kew's book.

I want my module to convert incoming messages into http requests so that
Apache is going to serve them using normal application server
infrastructure. This is what I, based on the info I have can easily do
using an input and output filter.

What I also need the protocol to be able to do is to send messages to the
client with no incoming data from the client. This may be based on a
timeout or based on a request coming from somewhere else (a tier-2
application server sending me a request on a totally different connection).

From what I have read so far, I could not find a hook that allows me to do
so. The only way that I could figure out how to do that is to modify
http_core.c and in ap_process_http_sync_connection query for either the
timeout or the separate even to have occured using some shared memory
technique. This however does not feel right to me. I would ideally like to
keep using http_core as it is without touching it.

Is there a way for me to wake up trigger the input filter chain even when
there is no data on the actual connection? I could then create a request
from the context of my persistent connection for a handler that I have
written that triggers the output filter chain to send the correct message.
Or even better is there a way I can trigger the output filter chain? Are
there hooks for this purpose?

I would very much appreciate a hint in the right direction.


Hello,

As your protocol is not http, I think that you should not execute ap_process_http_*_connection. ap_process_http_*_connection is a callback placed on the process_connection hook. I would suggest that you place your own protocol-specific callback on the process_connection hook. In your callback you get the socket descriptor and you perform "select" syscalls with timeout on the descriptor in a loop to get the timeout behaviour.

If you want to push data upon an incoming http request from a third-party, I think you cannot avoid the shared memory approach. The process that handles your http request has somehow to communicate with the process in which you handle the non-http connection to your client.

I've written something similar for SMPP and I remember I considered the filter implementation alternative but ultimately I did it without filters.

Sorin

Best regards,
Robert


Reply via email to