01-02-06 07:47 AM
[ http://issues.apache.org/jira/brows...ON-106?page=all ]
Graham Dumpleton updated MODPYTHON-106:
---------------------------------------
Attachment: mod_python.c.diff.20060102-1
Attached "mod_python.c.diff.20060102-1" which includes patch to fix problem
as described.
Note that diff line numbers on patch may not exactly agree with SVN head for
mod_python.c.
Should this be fixed in 3.2, given that it probably hasn't work in 3.0 and 3
.1?
> PythonAutoReload directive can't be turned off in config.
> ---------------------------------------------------------
>
> Key: MODPYTHON-106
> URL: http://issues.apache.org/jira/browse/MODPYTHON-106
> Project: mod_python
> Type: Bug
> Components: core
> Versions: 3.1.3, 3.2, 3.1.4
> Reporter: Graham Dumpleton
> Attachments: mod_python.c.diff.20060102-1
>
> In mod_python 2.7.11, the code for handling the PythonAutoReload directive
was:
> static const char *directive_PythonAutoReload(cmd_parms *cmd,
> void *mconfig, int val) {
> if (val)
> return python_directive(cmd, mconfig, "PythonAutoReload", "1");
> else
> return python_directive(cmd, mconfig, "PythonAutoReload", "0");
> }
> Thus, if PythonAutoReload was set to "Off", the config table object was lo
aded with PythonAutoReload set to "0".
> In mod_python 3.X at some point, it was changed to:
> static const char *python_directive_flag(void * mconfig,
> char *key, int val)
> {
> py_config *conf;
>
> conf = (py_config *) mconfig;
>
> if (val) {
> apr_table_set(conf->directives, key, "1");
> }
> else {
> apr_table_unset(conf->directives, key);
> }
>
> return NULL;
> }
> static const char *directive_PythonAutoReload(cmd_parms *cmd,
> void *mconfig, int val)
3;
> const char *rc = python_directive_flag(mconfig, "PythonAutoReload", va
l);
> if (!rc) {
> py_config *conf = ap_get_module_config(cmd->server->module_config,
> &python_module);
> return python_directive_flag(conf, "PythonAutoReload", val);
> }
> return rc;
> }
> Since that change, when PythonAutoReload was set ot "Off", no "0" value entry was
added to the config table object, instead, if there was an existing entry it was rem
oved. The removal would come into play when the option was set to "On" at global sco
pe
in main Apache configuration and then set to "Off" in a .htaccess file or other lesser scope
such as a Directory directive.
> The end result was that there was only an entry for PythonAutoReload in th
e config table object when it was set. When it existed, its value was "1".
> The problem now is that the code which checks for PythonAutoReload in mod_
python.apache module uses:
> module = import_module(module_name,
> autoreload=int(config.get("PythonAutoRe
load", 1)),
> log=debug)
> That is, if the PythonAutoReload option doesn't exist in the config table
object, it defaults to the auto reload feature being turned On.
> Thus, if PythonAutoReload is set to "On" in the configuration files, the Python co
de will find the value "1" and thus auto reload will be enabled. Because of the C co
de changes above though, when PythonAutoReload is set to "Off" in the config, no ent
ry
is put in the config table object at all and because the Python code can't find it, it defau
lts to using "1" with the result that auto reload will again be on.
> In other words, it isn't possible to turn the feature off through the Apac
he configuration directive.
> One solution is to change python_directive_flag() function to take an addi
tional argument whereby it can be specified that "0" should be set for the v
alue instead of the value being removed. Thus:
> static const char *python_directive_flag(void * mconfig,
> char *key, int val, int set)
> {
> py_config *conf;
> conf = (py_config *) mconfig;
> if (val) {
> apr_table_set(conf->directives, key, "1");
> }
> else {
> if (set) {
> apr_table_set(conf->directives, key, "0");
> }
> else {
> apr_table_unset(conf->directives, key);
> }
> }
> return NULL;
> }
> All calls to this function except for PythonAutoReload case should supply
"0" for additional argument, with "1" being supplied for PythonAutoReload ca
se.
> One can't just always set it to "0", as other code in mod_python.c uses the fact t
hat an option exists to mean it is set. Ie., it doesn't check the value, thus settin
g it to "0" will cause that code to think the option used in that case (PythonInterp
Per
Directory, PythonInterpPerDirective) is set to on when it isn't, thus causin
g that to stop working correctly.
[ Post a follow-up to this message ]
|