Mailing List Archive

Is this a bug, or am I being stupid?
If I have a module which has a server config entry and no dir config creator,
then I get a coredump in http_config.c. The following patch fixes it:

*** ../../apache_0.8.14-ben/src/http_config.c Tue Sep 19 17:04:59 1995
--- http_config.c Sun Oct 15 17:53:42 1995
***************
*** 498,503 ****
--- 498,506 ----
sconfig = (*mod->create_server_config)(parms->pool, parms->server);
set_module_config (parms->server->module_config, mod, sconfig);
}
+
+ if(!mconfig)
+ mconfig=sconfig;

return invoke_cmd (cmd, parms, mconfig, args);
}

(and displays seemingly correct behaviour). Is this a bug, or did I miss
something?

Cheers,

Ben.

--
Ben Laurie Phone: +44 (181) 994 6435
Freelance Consultant Fax: +44 (181) 994 6472
and Technical Director Email: ben@algroup.co.uk
A.L. Digital Ltd,
London, England.
Re: Is this a bug, or am I being stupid? [ In reply to ]
(and displays seemingly correct behaviour). Is this a bug, or did I miss
something?

I think you were missing something, though I'm not sure what --- what this
patch does is to pass the server config structure to the command handler
if no per-directory config structure exists. The behavior which a number
of modules expect is that if no per-directory config structure exists, they
get passed a NULL pointer.

The correct way to get at the per-server config structure is through
cmd_parms->server. I deliberately made this a bit more awkward than for
the per-directory case as a way of subtly encouraging people to make thing
configurable per directory where possible. We may want to revisit the
decision, but I'm pretty sure this isn't the right way to do it --- creating
a situation where the same argument to a command handler can be a per-dir
config structure in some cases, and a per-server config structure in other
cases, while leaving the module itself no way to tell the difference,
doesn't seem right.

rst
Re: Is this a bug, or am I being stupid? [ In reply to ]
>
> (and displays seemingly correct behaviour). Is this a bug, or did I miss
> something?
>
> I think you were missing something, though I'm not sure what --- what this
> patch does is to pass the server config structure to the command handler
> if no per-directory config structure exists. The behavior which a number
> of modules expect is that if no per-directory config structure exists, they
> get passed a NULL pointer.
>
> The correct way to get at the per-server config structure is through
> cmd_parms->server. I deliberately made this a bit more awkward than for
> the per-directory case as a way of subtly encouraging people to make thing
> configurable per directory where possible. We may want to revisit the
> decision, but I'm pretty sure this isn't the right way to do it --- creating
> a situation where the same argument to a command handler can be a per-dir
> config structure in some cases, and a per-server config structure in other
> cases, while leaving the module itself no way to tell the difference,
> doesn't seem right.

I agree with you. My problem is that I'm trying to use set_string_slot() to,
well, set a string slot. But it must be per-server. So, really, I need a
set_server_string_slot(). But, you can't write that (I don't think) because
the module is unknown (at this point), so you can't find the right structure.
Sigh. While we're on the subject, a set_[server_]int_slot() would be nice,
too.

BTW, set_string_slot() unnecessarily pstrdups() the string.

> rst

Cheers,

Ben.

--
Ben Laurie Phone: +44 (181) 994 6435
Freelance Consultant Fax: +44 (181) 994 6472
and Technical Director Email: ben@algroup.co.uk
A.L. Digital Ltd,
London, England.