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 Abitfarago Cini <ci...@gmail.com> on 2012/07/26 07:10:21 UTC

endless loop in my module

Hi,

I need in my Apache 2 module an endless loop what starts after the module
was loaded. Where should I put it?

#include <httpd.h>
#include <http_config.h>
#include <http_log.h>
#include <http_protocol.h>

static int xyz_handler(request_rec *r)
{
        if (!r->handler || strcmp(r->handler, "xyz"))
        {
                return DECLINED;
        }
        ...
        return OK;
}

static const char *set_xyz_configuration_file(
cmd_parms *parms, void *dummy,
                                               const char *url)
{
    return NULL;
}

static const command_rec xyz_cmds[] =
{
    AP_INIT_TAKE1("XyzConfigurationFile", set_xyz_configuration_file, NULL,
RSRC_CONF,
                  "The main configuration file"),
        {NULL}
};

static void register_hooks(apr_pool_t *p)
{
    ap_hook_handler(xyz_handler, NULL, NULL, APR_HOOK_MIDDLE);
}

module AP_MODULE_DECLARE_DATA glas_module =
{
    STANDARD20_MODULE_STUFF,
    NULL,                       /* dir config creater */
    NULL,                       /* dir merger --- default is to override */
    NULL,                       /* server config */
    NULL,                       /* merge server config */
    xyz_cmds,                   /* command table */
    register_hooks              /* register_hooks */
};

Thank you,
Abitfarago Cini

Re: endless loop in my module

Posted by Joe Lewis <jo...@joe-lewis.com>.
On 07/25/2012 11:10 PM, Abitfarago Cini wrote:
> Hi,
>
> I need in my Apache 2 module an endless loop what starts after the module
> was loaded. Where should I put it?
Are you trying to prevent Apache from doing's it's job?  Why would you 
want an endless loop?  What is the ultimate objective?

I'd not put an endless loop anywhere directly in a module.  If you have 
to use one, please fork another process off, and use that process to 
enter into an endless loop, then simply communicate with that process 
via a socket.  Adding an endless loop into an apache module has the 
potential to bring apache to it's knees.

Joe
--
http://www.silverhawk.net/