Permalink
Browse files

Relocates some internal information structures (structural clean up).

git-svn-id: svn://cherokee-project.com/cherokee/trunk@6735 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
1 parent 088e4eb commit 9a67d8716f637981a5037c9c2c922d1d415dabd7 @alobbs alobbs committed May 31, 2011
@@ -46,8 +46,8 @@ CHEROKEE_ADD_FUNC_NEW (config_entry);
CHEROKEE_ADD_FUNC_FREE (config_entry);
-ret_t
-cherokee_config_entry_init (cherokee_config_entry_t *entry)
+static ret_t
+init (struct cherokee_config_entry *entry)
{
entry->handler_new_func = NULL;
entry->handler_properties = NULL;
@@ -85,6 +85,13 @@ cherokee_config_entry_init (cherokee_config_entry_t *entry)
ret_t
+cherokee_config_entry_init (cherokee_config_entry_t *entry)
+{
+ return init (entry);
+}
+
+
+ret_t
cherokee_config_entry_mrproper (cherokee_config_entry_t *entry)
{
cherokee_list_t *i, *tmp;
@@ -304,3 +311,19 @@ cherokee_config_entry_print (cherokee_config_entry_t *entry)
return ret_ok;
}
+
+
+/* Entry reference
+ */
+
+ret_t
+cherokee_config_entry_ref_init (cherokee_config_entry_ref_t *entry)
+{
+ return init (entry);
+}
+
+ret_t
+cherokee_config_entry_ref_clean (cherokee_config_entry_ref_t *entry)
+{
+ return init (entry);
+}
@@ -69,7 +69,7 @@ typedef enum {
} cherokee_expiration_props_t;
-typedef struct {
+struct cherokee_config_entry {
/* Properties
*/
cherokee_buffer_t *document_root;
@@ -117,11 +117,15 @@ typedef struct {
*/
cherokee_null_int_t timeout_lapse;
cherokee_buffer_t *timeout_header;
-} cherokee_config_entry_t;
+};
-#define CONF_ENTRY(x) ((cherokee_config_entry_t *)(x))
+typedef struct cherokee_config_entry cherokee_config_entry_t;
+typedef struct cherokee_config_entry cherokee_config_entry_ref_t;
+#define CONF_ENTRY(x) ((cherokee_config_entry_t *)(x))
+/* Entry
+ */
ret_t cherokee_config_entry_new (cherokee_config_entry_t **entry);
ret_t cherokee_config_entry_free (cherokee_config_entry_t *entry);
ret_t cherokee_config_entry_init (cherokee_config_entry_t *entry);
@@ -140,4 +144,9 @@ ret_t cherokee_config_entry_complete (cherokee_config_entry_t *entry,
ret_t cherokee_config_entry_print (cherokee_config_entry_t *entry);
+/* Entry Reference
+ */
+ret_t cherokee_config_entry_ref_init (cherokee_config_entry_ref_t *entry);
+ret_t cherokee_config_entry_ref_clean (cherokee_config_entry_ref_t *entry);
+
#endif /* CHEROKEE_CONFIG_ENTRY_H */
@@ -67,6 +67,7 @@
#include "regex.h"
#include "bind.h"
#include "bogotime.h"
+#include "config_entry.h"
typedef enum {
phase_nothing,
@@ -104,6 +105,7 @@ struct cherokee_connection {
void *vserver;
void *thread;
cherokee_bind_t *bind;
+ cherokee_config_entry_ref_t config_entry;
/* ID
*/
@@ -137,7 +139,6 @@ struct cherokee_connection {
/* Headers
*/
cherokee_header_t header;
- cherokee_list_t *header_ops;
/* Encoders
*/
@@ -166,8 +167,6 @@ struct cherokee_connection {
/* Authentication
*/
cherokee_validator_t *validator; /* Validator object */
- cherokee_buffer_t *realm_ref; /* "My private data" */
-
cherokee_http_auth_t auth_type; /* Auth type of the resource */
cherokee_http_auth_t req_auth_type; /* Auth type of the request */
@@ -187,7 +186,6 @@ struct cherokee_connection {
*/
uint32_t keepalive;
time_t timeout;
-
time_t timeout_lapse;
cherokee_buffer_t *timeout_header;
@@ -207,8 +205,6 @@ struct cherokee_connection {
/* Front-line cache
*/
cherokee_flcache_conn_t flcache;
- cherokee_flcache_policy_t flcache_policy;
- cherokee_list_t *flcache_cookies_disregard;
/* Regular expressions
*/
View
@@ -107,7 +107,6 @@ cherokee_connection_new (cherokee_connection_t **conn)
n->range_end = -1;
n->vserver = NULL;
n->arguments = NULL;
- n->realm_ref = NULL;
n->mmaped = NULL;
n->mmaped_len = 0;
n->io_entry_ref = NULL;
@@ -131,9 +130,6 @@ cherokee_connection_new (cherokee_connection_t **conn)
n->limit_rate = false;
n->limit_bps = 0;
n->limit_blocked_until = 0;
- n->header_ops = NULL;
- n->flcache_cookies_disregard = NULL;
- n->flcache_policy = flcache_policy_explicitly_allowed;
cherokee_buffer_init (&n->buffer);
cherokee_buffer_init (&n->header_buffer);
@@ -174,6 +170,7 @@ cherokee_connection_new (cherokee_connection_t **conn)
n->chunked_last_package = false;
cherokee_buffer_init (&n->chunked_len);
+ cherokee_config_entry_ref_init (&n->config_entry);
cherokee_flcache_conn_init (&n->flcache);
*conn = n;
@@ -302,38 +299,34 @@ cherokee_connection_clean (cherokee_connection_t *conn)
conn->validator = NULL;
}
- conn->phase = phase_reading_header;
- conn->auth_type = http_auth_nothing;
- conn->req_auth_type = http_auth_nothing;
- conn->upgrade = http_upgrade_nothing;
- conn->options = conn_op_nothing;
- conn->error_code = http_ok;
- conn->range_start = -1;
- conn->range_end = -1;
- conn->logger_ref = NULL;
- conn->realm_ref = NULL;
- conn->mmaped = NULL;
- conn->mmaped_len = 0;
- conn->rx = 0;
- conn->tx = 0;
- conn->rx_partial = 0;
- conn->tx_partial = 0;
- conn->traffic_next = 0;
- conn->polling_multiple = false;
- conn->polling_mode = FDPOLL_MODE_NONE;
- conn->expiration = cherokee_expiration_none;
- conn->expiration_time = 0;
- conn->expiration_prop = cherokee_expiration_prop_none;
- conn->chunked_encoding = false;
- conn->chunked_sent = 0;
- conn->chunked_last_package = false;
- conn->respins = 0;
- conn->limit_rate = false;
- conn->limit_bps = 0;
- conn->limit_blocked_until = 0;
- conn->header_ops = NULL;
- conn->flcache_cookies_disregard = NULL;
- conn->flcache_policy = flcache_policy_explicitly_allowed;
+ conn->phase = phase_reading_header;
+ conn->auth_type = http_auth_nothing;
+ conn->req_auth_type = http_auth_nothing;
+ conn->upgrade = http_upgrade_nothing;
+ conn->options = conn_op_nothing;
+ conn->error_code = http_ok;
+ conn->range_start = -1;
+ conn->range_end = -1;
+ conn->logger_ref = NULL;
+ conn->mmaped = NULL;
+ conn->mmaped_len = 0;
+ conn->rx = 0;
+ conn->tx = 0;
+ conn->rx_partial = 0;
+ conn->tx_partial = 0;
+ conn->traffic_next = 0;
+ conn->polling_multiple = false;
+ conn->polling_mode = FDPOLL_MODE_NONE;
+ conn->expiration = cherokee_expiration_none;
+ conn->expiration_time = 0;
+ conn->expiration_prop = cherokee_expiration_prop_none;
+ conn->chunked_encoding = false;
+ conn->chunked_sent = 0;
+ conn->chunked_last_package = false;
+ conn->respins = 0;
+ conn->limit_rate = false;
+ conn->limit_bps = 0;
+ conn->limit_blocked_until = 0;
memset (conn->regex_ovector, 0, OVECTOR_LEN * sizeof(int));
conn->regex_ovecsize = 0;
@@ -364,6 +357,8 @@ cherokee_connection_clean (cherokee_connection_t *conn)
cherokee_buffer_clean (&conn->error_internal_url);
cherokee_buffer_clean (&conn->error_internal_qs);
+ cherokee_config_entry_ref_clean (&conn->config_entry);
+
if (conn->arguments != NULL) {
cherokee_avl_free (conn->arguments,
(cherokee_func_free_t) cherokee_buffer_free);
@@ -570,7 +565,7 @@ build_response_header_authentication (cherokee_connection_t *conn, cherokee_buff
*/
if (conn->auth_type & http_auth_basic) {
cherokee_buffer_add_str (buffer, "WWW-Authenticate: Basic realm=\"");
- cherokee_buffer_add_buffer (buffer, conn->realm_ref);
+ cherokee_buffer_add_buffer (buffer, conn->config_entry.auth_realm);
cherokee_buffer_add_str (buffer, "\""CRLF);
}
@@ -585,7 +580,7 @@ build_response_header_authentication (cherokee_connection_t *conn, cherokee_buff
/* Realm
*/
cherokee_buffer_add_str (buffer, "WWW-Authenticate: Digest realm=\"");
- cherokee_buffer_add_buffer (buffer, conn->realm_ref);
+ cherokee_buffer_add_buffer (buffer, conn->config_entry.auth_realm);
cherokee_buffer_add_str (buffer, "\", ");
/* Nonce:
@@ -809,7 +804,7 @@ build_response_header (cherokee_connection_t *conn,
/* Authentication
*/
- if (conn->realm_ref != NULL) {
+ if (conn->config_entry.auth_realm != NULL) {
if ((conn->error_code == http_unauthorized) ||
(conn->error_internal_code == http_unauthorized))
{
@@ -867,8 +862,8 @@ build_response_header_final (cherokee_connection_t *conn,
/* Headers ops:
* This must be the last operation
*/
- if (conn->header_ops) {
- cherokee_header_op_render (conn->header_ops, &conn->buffer);
+ if (conn->config_entry.header_ops) {
+ cherokee_header_op_render (conn->config_entry.header_ops, &conn->buffer);
}
}
@@ -1824,8 +1819,6 @@ ret_t
cherokee_connection_set_custom_droot (cherokee_connection_t *conn,
cherokee_config_entry_t *entry)
{
- ret_t ret;
-
/* Shortcut
*/
if ((entry->document_root == NULL) ||
@@ -1837,7 +1830,7 @@ cherokee_connection_set_custom_droot (cherokee_connection_t *conn,
BIT_SET (conn->options, conn_op_document_root);
cherokee_buffer_clean (&conn->local_directory);
- ret = cherokee_buffer_add_buffer (&conn->local_directory, entry->document_root);
+ cherokee_buffer_add_buffer (&conn->local_directory, entry->document_root);
/* It has to drop the webdir from the request:
*
@@ -2348,6 +2341,20 @@ cherokee_connection_create_handler (cherokee_connection_t *conn, cherokee_config
case ret_ok:
case ret_eof:
case ret_eagain:
+ /* Trace the name of the new handler
+ */
+#ifdef TRACE_ENABLED
+ if ((conn->handler != NULL) &&
+ (cherokee_trace_is_tracing()))
+ {
+ char *name = NULL;
+
+ ret = cherokee_module_get_name (MODULE (conn->handler), &name);
+ if ((ret == ret_ok) && (name != NULL)) {
+ TRACE(ENTRIES",handler", "Instanced handler: '%s'\n", name);
+ }
+ }
+#endif
return ret;
default:
if ((conn->handler == NULL) &&
View
@@ -525,13 +525,13 @@ inspect_header (cherokee_flcache_conn_t *flcache_conn,
/* Set-cookie
*/
else if (strncasecmp (begin, "Set-cookie:", 11) == 0) {
- if (conn->flcache_cookies_disregard) {
+ if (conn->config_entry.flcache_cookies_disregard) {
int re;
void *pcre;
cherokee_list_t *i;
cherokee_boolean_t matched = false;
- list_for_each (i, conn->flcache_cookies_disregard) {
+ list_for_each (i, conn->config_entry.flcache_cookies_disregard) {
pcre = LIST_ITEM_INFO(i);
re = pcre_exec (pcre, NULL, begin, end-begin, 0, 0, NULL, 0);
@@ -600,7 +600,7 @@ inspect_header (cherokee_flcache_conn_t *flcache_conn,
/* Check the caching policy
*/
if ((! do_cache) &&
- (conn->flcache_policy == flcache_policy_explicitly_allowed))
+ (conn->config_entry.flcache_policy == flcache_policy_explicitly_allowed))
{
TRACE(ENTRIES, "Doesn't explicitly allow caching.%s", "\n");
return ret_deny;
View
@@ -64,8 +64,6 @@ static void
update_connection (cherokee_connection_t *conn,
cherokee_config_entry_t *ret_config)
{
- if (! conn->realm_ref)
- conn->realm_ref = ret_config->auth_realm;
if (! conn->auth_type)
conn->auth_type = ret_config->authentication;
@@ -76,6 +74,11 @@ update_connection (cherokee_connection_t *conn,
conn->expiration_time = ret_config->expiration_time;
conn->expiration_prop = ret_config->expiration_prop;
}
+
+ if (! NULLI_IS_NULL(ret_config->timeout_lapse)) {
+ conn->timeout_lapse = ret_config->timeout_lapse;
+ conn->timeout_header = ret_config->timeout_header;
+ }
}
ret_t
@@ -111,15 +114,9 @@ cherokee_rule_list_match (cherokee_rule_list_t *list,
TRACE(ENTRIES, "Merging rule prio=%d\n", rule->priority);
cherokee_config_entry_complete (ret_config, &rule->config);
- /* Update the connection
- */
- update_connection (conn, ret_config);
-
/* Should it continue? */
if (rule->final) {
- TRACE(ENTRIES, "Final rule prio=%d. Exiting.\n",
- rule->priority);
- return ret_ok;
+ goto out;
}
}
@@ -128,10 +125,10 @@ cherokee_rule_list_match (cherokee_rule_list_t *list,
list->def_rule->match(list->def_rule, conn, ret_config);
cherokee_config_entry_complete (ret_config, &list->def_rule->config);
+out:
/* Update the connection
*/
update_connection (conn, ret_config);
-
return ret_ok;
}
Oops, something went wrong.

0 comments on commit 9a67d87

Please sign in to comment.