Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Cherokee: commits

[6841] cherokee/trunk: Complex rule matches (and, or and not) accesses now the right internal

 

 

Cherokee commits RSS feed   Index | Next | Previous | View Threaded


cherokee at cherokee-project

Sep 7, 2011, 5:56 AM

Post #1 of 1 (154 views)
Permalink
[6841] cherokee/trunk: Complex rule matches (and, or and not) accesses now the right internal

Revision: 6841
http://svn.cherokee-project.com/changeset/6841
Author: alo
Date: 2011-09-07 14:56:18 +0200 (Wed, 07 Sep 2011)
Log Message:
-----------
Complex rule matches (and, or and not) accesses now the right internal
configuration objects. Besides fixing the server core issue, this
patch also adds a new QA test entry to project us against potential
regressions. It fixes bug #1207: http://bugs.cherokee-project.com/1207

Modified Paths:
--------------
cherokee/trunk/cherokee/rule.c
cherokee/trunk/cherokee/rule.h
cherokee/trunk/cherokee/rule_and.c
cherokee/trunk/cherokee/rule_directory.c
cherokee/trunk/cherokee/rule_not.c
cherokee/trunk/cherokee/rule_or.c
cherokee/trunk/qa/Makefile.am

Added Paths:
-----------
cherokee/trunk/qa/287-rule-inheritance.py

Modified: cherokee/trunk/cherokee/rule.c
===================================================================
--- cherokee/trunk/cherokee/rule.c 2011-09-06 20:02:59 UTC (rev 6840)
+++ cherokee/trunk/cherokee/rule.c 2011-09-07 12:56:18 UTC (rev 6841)
@@ -36,9 +36,10 @@
cherokee_module_init_base (MODULE(rule), NULL, info);
INIT_LIST_HEAD (&rule->list_node);

- rule->match = NULL;
- rule->final = true;
- rule->priority = CHEROKEE_RULE_PRIO_NONE;
+ rule->match = NULL;
+ rule->final = true;
+ rule->priority = CHEROKEE_RULE_PRIO_NONE;
+ rule->parent_rule = NULL;

cherokee_config_entry_init (&rule->config);
return ret_ok;
@@ -115,3 +116,16 @@
return rule->match (rule, CONN(cnt), CONF_ENTRY(ret_conf));
}

+
+void
+cherokee_rule_get_config (cherokee_rule_t *rule,
+ cherokee_config_entry_t **config)
+{
+ cherokee_rule_t *r = rule;
+
+ while (r->parent_rule != NULL) {
+ r = r->parent_rule;
+ }
+
+ *config = &r->config;
+}

Modified: cherokee/trunk/cherokee/rule.h
===================================================================
--- cherokee/trunk/cherokee/rule.h 2011-09-06 20:02:59 UTC (rev 6840)
+++ cherokee/trunk/cherokee/rule.h 2011-09-07 12:56:18 UTC (rev 6841)
@@ -49,7 +49,7 @@

/* Data types
*/
-typedef struct {
+struct cherokee_rule {
cherokee_module_t module;

/* Properties */
@@ -58,12 +58,14 @@

cherokee_boolean_t final;
cuint_t priority;
+ struct cherokee_rule *parent_rule;

/* Virtual methods */
rule_func_match_t match;
rule_func_configure_t configure;
-} cherokee_rule_t;
+};

+typedef struct cherokee_rule cherokee_rule_t;
#define RULE(x) ((cherokee_rule_t *)(x))

/* Easy initialization
@@ -90,6 +92,10 @@
ret_t cherokee_rule_match (cherokee_rule_t *rule, void *cnt, void *ret_conf);
ret_t cherokee_rule_configure (cherokee_rule_t *rule, cherokee_config_node_t *conf, void *vsrv);

+/* Utilities
+ */
+void cherokee_rule_get_config (cherokee_rule_t *rule, cherokee_config_entry_t **config);
+
CHEROKEE_END_DECLS

#endif /* CHEROKEE_RULE_H */

Modified: cherokee/trunk/cherokee/rule_and.c
===================================================================
--- cherokee/trunk/cherokee/rule_and.c 2011-09-06 20:02:59 UTC (rev 6840)
+++ cherokee/trunk/cherokee/rule_and.c 2011-09-07 12:56:18 UTC (rev 6841)
@@ -71,9 +71,17 @@
ret = cherokee_virtual_server_new_rule (vsrv, subconf,
RULE(rule)->priority,
branch_rule);
+
if (ret != ret_ok)
return ret;

+ if ((branch_rule == NULL) || (*branch_rule) == NULL)
+ return ret_error;
+
+ /* Let the child rule know about its parent
+ */
+ (*branch_rule)->parent_rule = RULE(rule);
+
return ret_ok;
}


Modified: cherokee/trunk/cherokee/rule_directory.c
===================================================================
--- cherokee/trunk/cherokee/rule_directory.c 2011-09-06 20:02:59 UTC (rev 6840)
+++ cherokee/trunk/cherokee/rule_directory.c 2011-09-07 12:56:18 UTC (rev 6841)
@@ -38,6 +38,8 @@
cherokee_connection_t *conn,
cherokee_config_entry_t *ret_conf)
{
+ cherokee_config_entry_t *conf = NULL;
+
UNUSED(ret_conf);

/* Not the same lenght
@@ -90,8 +92,10 @@

/* Copy the web directory property
*/
- if ((RULE(rule)->config.handler_new_func != NULL) ||
- (RULE(rule)->config.document_root != NULL))
+ cherokee_rule_get_config (RULE(rule), &conf);
+
+ if ((conf->document_root != NULL) ||
+ (conf->handler_new_func != NULL))
{
cherokee_buffer_clean (&conn->web_directory);
cherokee_buffer_add_buffer (&conn->web_directory, &rule->directory);

Modified: cherokee/trunk/cherokee/rule_not.c
===================================================================
--- cherokee/trunk/cherokee/rule_not.c 2011-09-06 20:02:59 UTC (rev 6840)
+++ cherokee/trunk/cherokee/rule_not.c 2011-09-07 12:56:18 UTC (rev 6841)
@@ -76,6 +76,13 @@
if (ret != ret_ok)
return ret;

+ if (rule->right == NULL)
+ return ret_error;
+
+ /* Let the child rule know about its parent
+ */
+ rule->right->parent_rule = RULE(rule);
+
return ret_ok;
}


Modified: cherokee/trunk/cherokee/rule_or.c
===================================================================
--- cherokee/trunk/cherokee/rule_or.c 2011-09-06 20:02:59 UTC (rev 6840)
+++ cherokee/trunk/cherokee/rule_or.c 2011-09-07 12:56:18 UTC (rev 6841)
@@ -73,6 +73,13 @@
if (ret != ret_ok)
return ret;

+ if ((branch_rule == NULL) || (*branch_rule) == NULL)
+ return ret_error;
+
+ /* Let the child rule know about its parent
+ */
+ (*branch_rule)->parent_rule = RULE(rule);
+
return ret_ok;
}


Added: cherokee/trunk/qa/287-rule-inheritance.py
===================================================================
--- cherokee/trunk/qa/287-rule-inheritance.py (rev 0)
+++ cherokee/trunk/qa/287-rule-inheritance.py 2011-09-07 12:56:18 UTC (rev 6841)
@@ -0,0 +1,36 @@
+from base import *
+
+# Tests: http://bugs.cherokee-project.com/1207
+#
+# When using a complex rule match, the child match objects were
+# accessing their own (empty) configuration objects instead of its
+# parents where the real configuration was found.
+
+DIR_WEB = "web287"
+DIR_LOCAL = "DirAnd-parent_properties"
+FILE = "filename_to_be_found"
+
+CONF = """
+vserver!1!rule!2870!match = and
+vserver!1!rule!2870!match!left = directory
+vserver!1!rule!2870!match!left!directory = /%s
+vserver!1!rule!2870!match!right = request
+vserver!1!rule!2870!match!right!request = .*
+vserver!1!rule!2870!handler = dirlist
+vserver!1!rule!2870!document_root = %s
+"""
+
+class Test (TestBase):
+ def __init__ (self):
+ TestBase.__init__ (self, __file__)
+ self.name = "Complex rules: props inheritance"
+
+ self.request = "GET /%s/ HTTP/1.0\r\n" % (DIR_WEB)
+ self.expected_error = 200
+ self.expected_content = FILE
+
+ def Prepare (self, www):
+ d = self.Mkdir (www, DIR_LOCAL)
+ self.WriteFile (d, FILE)
+
+ self.conf = CONF %(DIR_WEB, d)

Modified: cherokee/trunk/qa/Makefile.am
===================================================================
--- cherokee/trunk/qa/Makefile.am 2011-09-06 20:02:59 UTC (rev 6840)
+++ cherokee/trunk/qa/Makefile.am 2011-09-07 12:56:18 UTC (rev 6841)
@@ -307,7 +307,8 @@
283-Flcache-expired3.py \
284-SSI-include-recursive.py \
285-Flcache-overwrite.py \
-286-CGI-Permissions.py
+286-CGI-Permissions.py \
+287-rule-inheritance.py

test:
python -m compileall .

Cherokee commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.