httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <sor...@gmail.com>
Subject Re: Socket transfer from Apache httpd to a non-httpd process
Date Thu, 16 Jun 2011 10:09:59 GMT
On Thu, Jun 16, 2011 at 10:32, Henrik Strand <henrik.strand@axis.com> wrote:
> Hi,
>
> I need to transfer the socket descriptor for a client
> connection from the Apache httpd process to a non-httpd process running
> on the same system as Apache httpd, thus transferring the server
> response responsibility from Apache httpd to the non-httpd process
> (i.e., the Apache httpd process must not reply anything to the client).
>
> The way I need to do this is due to legacy code and I need to implement
> it in C.
>

Have a look at mod_cgid.

I think you cannot dupe apache into not closing the socket. The apache
thread must wait until your daemon is done with the socket. Maybe you
could make the apache thread sleep after it passes the socket to the
daemon and wait to be woken up by the daemon.

>
> I've tried writing a module that uses ap_hook_pre_connection(...) where
> I then send the socket descriptor via sendmsg(...) with something like
> this:
>
> static int fdipc_pre_connection(conn_rec *c, void *csd)
> {
>    apr_os_sock_t sock;
>    apr_os_sock_get(&sock, csd);
>
>    ...
>
>    sendmsg(...);
>
>    ...
>
>    return DONE;
> }
>
> static void fdipc_register_hooks(apr_pool_t *p)
> {
>    ap_hook_pre_connection(fdipc_pre_connection, NULL, NULL,
> APR_HOOK_MIDDLE);
> }
>
>
> I've tried writing data to the socket directly after my non-httpd daemon
> process receives the socket descriptor and this results in that the
> client receives this data. However, very shortly afterwards the
> connections is closed and I'm not able to write to the socket anymore.
>
>
> Is this the right way to transfer the socket descriptor to a non-httpd
> daemon process? If so, what am I missing in order to make it work?
>
> Thanks in advance.
>
> Best Regards,
> Henrik
>
>
>

Mime
View raw message