comparison src/http/ngx_http_core_module.h @ 477:ad1e9ebf93bb release-0.1.13

nginx-0.1.13-RELEASE import *) Feature: the server_names_hash and server_names_hash_threshold directives. *) Bugfix: the *.domain.tld names in the "server_name" directive did not work. *) Bugfix: the %request_length log parameter logged the incorrect length.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 21 Dec 2004 12:30:30 +0000
parents bbd6b0b4a2b1
children c52408583801
comparison
equal deleted inserted replaced
476:7e8b84ab09e9 477:ad1e9ebf93bb
12 #include <ngx_array.h> 12 #include <ngx_array.h>
13 #include <ngx_http.h> 13 #include <ngx_http.h>
14 14
15 15
16 typedef struct { 16 typedef struct {
17 in_addr_t addr; 17 in_addr_t addr;
18 in_port_t port; 18 in_port_t port;
19 int family; 19 int family;
20 ngx_str_t file_name; 20 ngx_str_t file_name;
21 int line; 21 ngx_int_t line;
22 22
23 unsigned default_server:1; 23 unsigned default_server:1;
24 } ngx_http_listen_t; 24 } ngx_http_listen_t;
25 25
26 26
27 typedef enum { 27 typedef enum {
28 NGX_HTTP_REWRITE_PHASE = 0, 28 NGX_HTTP_REWRITE_PHASE = 0,
35 NGX_HTTP_LAST_PHASE 35 NGX_HTTP_LAST_PHASE
36 } ngx_http_phases; 36 } ngx_http_phases;
37 37
38 38
39 typedef struct { 39 typedef struct {
40 ngx_array_t handlers; 40 ngx_array_t handlers;
41 ngx_int_t type; /* NGX_OK, NGX_DECLINED */ 41 ngx_int_t type; /* NGX_OK, NGX_DECLINED */
42 } ngx_http_phase_t; 42 } ngx_http_phase_t;
43 43
44 44
45 typedef struct { 45 typedef struct {
46 ngx_array_t servers; /* array of ngx_http_core_srv_conf_t */ 46 ngx_array_t servers; /* array of ngx_http_core_srv_conf_t */
47 47
48 ngx_http_phase_t phases[NGX_HTTP_LAST_PHASE]; 48 ngx_http_phase_t phases[NGX_HTTP_LAST_PHASE];
49 ngx_array_t index_handlers; 49 ngx_array_t index_handlers;
50 50
51 size_t max_server_name_len; 51 ngx_uint_t server_names_hash;
52 ngx_uint_t server_names_hash_threshold;
53
54 size_t max_server_name_len;
52 } ngx_http_core_main_conf_t; 55 } ngx_http_core_main_conf_t;
53 56
54 57
55 typedef struct { 58 typedef struct {
56 /* 59 /*
57 * array of ngx_http_core_loc_conf_t, used in the translation handler 60 * array of ngx_http_core_loc_conf_t, used in the translation handler
58 * and in the merge phase 61 * and in the merge phase
59 */ 62 */
60 ngx_array_t locations; 63 ngx_array_t locations;
61 64
62 /* "listen", array of ngx_http_listen_t */ 65 /* "listen", array of ngx_http_listen_t */
63 ngx_array_t listen; 66 ngx_array_t listen;
64 67
65 /* "server_name", array of ngx_http_server_name_t */ 68 /* "server_name", array of ngx_http_server_name_t */
66 ngx_array_t server_names; 69 ngx_array_t server_names;
67 70
68 /* server ctx */ 71 /* server ctx */
69 ngx_http_conf_ctx_t *ctx; 72 ngx_http_conf_ctx_t *ctx;
70 73
71 size_t connection_pool_size; 74 size_t connection_pool_size;
72 size_t request_pool_size; 75 size_t request_pool_size;
73 size_t client_header_buffer_size; 76 size_t client_header_buffer_size;
74 77
75 ngx_bufs_t large_client_header_buffers; 78 ngx_bufs_t large_client_header_buffers;
76 79
77 ngx_msec_t post_accept_timeout; 80 ngx_msec_t post_accept_timeout;
78 ngx_msec_t client_header_timeout; 81 ngx_msec_t client_header_timeout;
79 82
80 ngx_uint_t restrict_host_names; 83 ngx_uint_t restrict_host_names;
81 } ngx_http_core_srv_conf_t; 84 } ngx_http_core_srv_conf_t;
82 85
83 86
84 /* list of structures to find core_srv_conf quickly at run time */ 87 /* list of structures to find core_srv_conf quickly at run time */
85 88
86 typedef struct { 89 typedef struct {
87 in_port_t port; 90 in_port_t port;
88 ngx_str_t port_text; 91 ngx_str_t port_text;
89 ngx_array_t addrs; /* array of ngx_http_in_addr_t */ 92 ngx_array_t addrs; /* array of ngx_http_in_addr_t */
90 } ngx_http_in_port_t; 93 } ngx_http_in_port_t;
91 94
92 95
93 typedef struct { 96 struct ngx_http_in_addr_s {
94 in_addr_t addr; 97 in_addr_t addr;
98
95 ngx_array_t names; /* array of ngx_http_server_name_t */ 99 ngx_array_t names; /* array of ngx_http_server_name_t */
96 ngx_http_core_srv_conf_t *core_srv_conf; /* default server conf 100 ngx_array_t *hash; /* hash of ngx_http_server_name_t */
97 for this address:port */ 101 ngx_array_t wildcards; /* array of ngx_http_server_name_t */
102
103 /* the default server configuration for this address:port */
104 ngx_http_core_srv_conf_t *core_srv_conf;
98 105
99 ngx_uint_t default_server; /* unsigned default_server:1; */ 106 ngx_uint_t default_server; /* unsigned default_server:1; */
100 } ngx_http_in_addr_t; 107 };
101 108
102 109
103 typedef struct { 110 typedef struct {
104 ngx_str_t name; 111 ngx_str_t name;
105 ngx_http_core_srv_conf_t *core_srv_conf; /* virtual name server conf */ 112 ngx_http_core_srv_conf_t *core_srv_conf; /* virtual name server conf */
106 113
107 ngx_uint_t wildcard; /*unsigned wildcard:1; */ 114 ngx_uint_t wildcard; /* unsigned wildcard:1 */
108 } ngx_http_server_name_t; 115 } ngx_http_server_name_t;
116
117
118 #define ngx_http_server_names_hash_key(key, name, len, prime) \
119 { \
120 ngx_uint_t n; \
121 for (key = 0, n = 0; n < len; n++) { \
122 key += name[n]; \
123 } \
124 key %= prime; \
125 }
109 126
110 127
111 #define NGX_HTTP_TYPES_HASH_PRIME 13 128 #define NGX_HTTP_TYPES_HASH_PRIME 13
112 129
113 #define ngx_http_types_hash_key(key, ext) \ 130 #define ngx_http_types_hash_key(key, ext) \
114 { \ 131 { \
115 u_int n; \ 132 ngx_uint_t n; \
116 for (key = 0, n = 0; n < ext.len; n++) { \ 133 for (key = 0, n = 0; n < ext.len; n++) { \
117 key += ext.data[n]; \ 134 key += ext.data[n]; \
118 } \ 135 } \
119 key %= NGX_HTTP_TYPES_HASH_PRIME; \ 136 key %= NGX_HTTP_TYPES_HASH_PRIME; \
120 } 137 }
121 138
122 typedef struct { 139 typedef struct {
123 ngx_str_t exten; 140 ngx_str_t exten;
124 ngx_str_t type; 141 ngx_str_t type;
125 } ngx_http_type_t; 142 } ngx_http_type_t;
126 143
127 144
128 typedef struct { 145 typedef struct {
129 ngx_int_t status; 146 ngx_int_t status;
130 ngx_int_t overwrite; 147 ngx_int_t overwrite;
131 ngx_str_t uri; 148 ngx_str_t uri;
132 } ngx_http_err_page_t; 149 } ngx_http_err_page_t;
133 150
134 151
135 typedef struct ngx_http_core_loc_conf_s ngx_http_core_loc_conf_t; 152 typedef struct ngx_http_core_loc_conf_s ngx_http_core_loc_conf_t;
136 153