Changeset 1465
- Timestamp:
- 12/12/2006 10:13:38 PM (22 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 2 removed
- 33 modified
-
configure.in (modified) (1 diff)
-
src/Makefile.am (modified) (5 diffs)
-
src/array-static.h (modified) (2 diffs)
-
src/array.c (modified) (1 diff)
-
src/array.h (modified) (2 diffs)
-
src/base.h (modified) (1 diff)
-
src/buffer.c (modified) (1 diff)
-
src/chunk.c (modified) (1 diff)
-
src/chunk.h (modified) (1 diff)
-
src/connections.c (modified) (11 diffs)
-
src/fdevent_freebsd_kqueue.c (modified) (1 diff)
-
src/http_resp.c (modified) (3 diffs)
-
src/http_resp_parser.y (modified) (1 diff)
-
src/joblist.c (modified) (1 diff)
-
src/mod_auth.c (modified) (1 diff)
-
src/mod_indexfile.c (modified) (1 diff)
-
src/mod_proxy_backend_fastcgi.c (modified) (16 diffs)
-
src/mod_proxy_backend_fastcgi.h (deleted)
-
src/mod_proxy_backend_http.c (modified) (9 diffs)
-
src/mod_proxy_backend_http.h (deleted)
-
src/mod_proxy_backend_scgi.c (added)
-
src/mod_proxy_core.c (modified) (40 diffs)
-
src/mod_proxy_core.h (modified) (7 diffs)
-
src/mod_proxy_core_address.c (modified) (1 diff)
-
src/mod_proxy_core_backend.c (modified) (2 diffs)
-
src/mod_proxy_core_backend.h (modified) (2 diffs)
-
src/mod_proxy_core_protocol.c (added)
-
src/mod_proxy_core_protocol.h (added)
-
src/mod_proxy_core_rewrites.c (modified) (1 diff)
-
src/mod_staticfile.c (modified) (1 diff)
-
src/mod_status.c (modified) (1 diff)
-
src/network_linux_aio.c (modified) (2 diffs)
-
src/network_posix_aio.c (modified) (1 diff)
-
src/plugin.c (modified) (1 diff)
-
src/plugin.h (modified) (2 diffs)
-
src/response.c (modified) (1 diff)
-
src/server.c (modified) (4 diffs)
-
src/sys-files.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.in
r1457 r1465 564 564 565 565 566 do_build="mod_ cgi mod_fastcgi mod_proxy mod_evhost mod_simple_vhost mod_access mod_alias mod_setenv mod_usertrack mod_auth mod_status mod_accesslog mod_rrdtool mod_secdownload mod_expire mod_compress mod_dirlisting mod_indexfiles mod_userdir mod_webdav mod_staticfile mod_scgimod_flv_streaming"566 do_build="mod_proxy_core mod_proxy_backend_http mod_proxy_backend_fastcgi mod_proxy_backend_scgi mod_evhost mod_simple_vhost mod_access mod_alias mod_setenv mod_usertrack mod_auth mod_status mod_accesslog mod_rrdtool mod_secdownload mod_expire mod_compress mod_dirlisting mod_indexfiles mod_userdir mod_webdav mod_staticfile mod_flv_streaming" 567 567 568 568 plugins="mod_rewrite mod_redirect mod_ssi mod_trigger_b4_dl" -
trunk/src/Makefile.am
r1457 r1465 53 53 stat_cache.c plugin.c joblist.c etag.c array.c \ 54 54 data_string.c data_count.c data_array.c \ 55 data_integer.c md5.c data_fastcgi.c\55 data_integer.c md5.c \ 56 56 fdevent_select.c fdevent_linux_rtsig.c \ 57 57 fdevent_poll.c fdevent_linux_sysepoll.c \ … … 137 137 mod_sql_vhost_core_la_LIBADD = $(common_libadd) 138 138 139 #lib_LTLIBRARIES += mod_cgi.la140 #mod_cgi_la_SOURCES = mod_cgi.c141 #mod_cgi_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined142 #mod_cgi_la_LIBADD = $(common_libadd)143 144 #lib_LTLIBRARIES += mod_scgi.la145 #mod_scgi_la_SOURCES = mod_scgi.c146 #mod_scgi_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined147 #mod_scgi_la_LIBADD = $(common_libadd)148 149 139 lib_LTLIBRARIES += mod_staticfile.la 150 140 mod_staticfile_la_SOURCES = mod_staticfile.c … … 187 177 mod_usertrack_la_LIBADD = $(common_libadd) 188 178 189 #lib_LTLIBRARIES += mod_proxy.la190 #mod_proxy_la_SOURCES = mod_proxy.c191 #mod_proxy_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined192 #mod_proxy_la_LIBADD = $(common_libadd)193 194 179 lib_LTLIBRARIES += mod_proxy_core.la 195 180 mod_proxy_core_la_SOURCES = mod_proxy_core.c mod_proxy_core_pool.c \ 196 181 mod_proxy_core_backend.c mod_proxy_core_address.c \ 197 182 mod_proxy_core_backlog.c mod_proxy_core_rewrites.c \ 198 mod_proxy_ backend_http.c mod_proxy_backend_fastcgi.c183 mod_proxy_core_protocol.c 199 184 mod_proxy_core_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined 200 185 mod_proxy_core_la_LIBADD = $(common_libadd) $(PCRE_LIB) 186 187 lib_LTLIBRARIES += mod_proxy_backend_http.la 188 mod_proxy_backend_http_la_SOURCES = mod_proxy_backend_http.c 189 mod_proxy_backend_http_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined 190 mod_proxy_backend_http_la_LIBADD = $(common_libadd) $(PCRE_LIB) 191 192 lib_LTLIBRARIES += mod_proxy_backend_fastcgi.la 193 mod_proxy_backend_fastcgi_la_SOURCES = mod_proxy_backend_fastcgi.c 194 mod_proxy_backend_fastcgi_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined 195 mod_proxy_backend_fastcgi_la_LIBADD = $(common_libadd) $(PCRE_LIB) 196 197 lib_LTLIBRARIES += mod_proxy_backend_scgi.la 198 mod_proxy_backend_scgi_la_SOURCES = mod_proxy_backend_scgi.c 199 mod_proxy_backend_scgi_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined 200 mod_proxy_backend_scgi_la_LIBADD = $(common_libadd) $(PCRE_LIB) 201 201 202 202 … … 231 231 mod_simple_vhost_la_LIBADD = $(common_libadd) 232 232 233 #lib_LTLIBRARIES += mod_fastcgi.la234 #mod_fastcgi_la_SOURCES = mod_fastcgi.c235 #mod_fastcgi_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined236 #mod_fastcgi_la_LIBADD = $(common_libadd)237 238 233 lib_LTLIBRARIES += mod_access.la 239 234 mod_access_la_SOURCES = mod_access.c … … 292 287 mod_proxy_core_pool.h \ 293 288 mod_proxy_core_rewrites.h \ 294 mod_proxy_backend_http.h \295 mod_proxy_backend_fastcgi.h \296 289 status_counter.h \ 297 290 http_req.h \ -
trunk/src/array-static.h
r1349 r1465 24 24 } 25 25 26 #define FOREACH(array, element, func) \27 do { size_t _i; for (_i = 0; _i < array->used; _i++) { void*element = array->ptr[_i]; func; } } while(0);26 #define FOREACH(array, type, element, func) \ 27 do { size_t _i; for (_i = 0; _i < array->used; _i++) { type *element = array->ptr[_i]; func; } } while(0); 28 28 29 29 #define STRUCT_INIT(type, var) \ … … 31 31 var = calloc(1, sizeof(*var)) 32 32 33 #define ARRAY_STATIC_FREE(array, type, element, func) \ 34 FOREACH(array, type, element, func); \ 35 if(array->ptr) free(array->ptr); \ 36 array->ptr = NULL; 37 33 38 #endif -
trunk/src/array.c
r1349 r1465 145 145 146 146 return ds; 147 } 148 149 void array_set_key_value(array *hdrs, const char *key, size_t key_len, const char *value, size_t val_len) { 150 data_string *ds_dst; 151 152 if (NULL != (ds_dst = (data_string *)array_get_element(hdrs, key))) { 153 buffer_copy_string_len(ds_dst->value, value, val_len); 154 return; 155 } 156 157 if (NULL == (ds_dst = (data_string *)array_get_unused_element(hdrs, TYPE_STRING))) { 158 ds_dst = data_string_init(); 159 } 160 161 buffer_copy_string_len(ds_dst->key, key, key_len); 162 buffer_copy_string_len(ds_dst->value, value, val_len); 163 array_insert_unique(hdrs, (data_unset *)ds_dst); 164 } 165 166 void array_append_key_value(array *hdrs, const char *key, size_t key_len, const char *value, size_t val_len) { 167 data_string *ds_dst; 168 169 if (NULL == (ds_dst = (data_string *)array_get_unused_element(hdrs, TYPE_STRING))) { 170 ds_dst = data_string_init(); 171 } 172 173 buffer_copy_string_len(ds_dst->key, key, key_len); 174 buffer_copy_string_len(ds_dst->value, value, val_len); 175 array_insert_unique(hdrs, (data_unset *)ds_dst); 147 176 } 148 177 -
trunk/src/array.h
r1349 r1465 135 135 data_integer *data_integer_init(void); 136 136 137 typedef struct {138 DATA_UNSET;139 140 buffer *host;141 142 unsigned short port;143 144 time_t disable_ts;145 int is_disabled;146 size_t balance;147 148 int usage; /* fair-balancing needs the no. of connections active on this host */149 int last_used_ndx; /* round robin */150 } data_fastcgi;151 152 data_fastcgi *data_fastcgi_init(void);153 154 137 array *array_init(void); 155 138 array *array_init_array(array *a); … … 161 144 data_unset *array_get_unused_element(array *a, data_type_t t); 162 145 data_unset *array_get_element(array *a, const char *key); 146 void array_set_key_value(array *hdrs, const char *key, size_t key_len, const char *value, size_t val_len); 147 void array_append_key_value(array *hdrs, const char *key, size_t key_len, const char *value, size_t val_len); 163 148 data_unset *array_replace(array *a, data_unset *du); 164 149 int array_strcasecmp(const char *a, size_t a_len, const char *b, size_t b_len); -
trunk/src/base.h
r1462 r1465 560 560 connections *conns; 561 561 connections *joblist; 562 connections *joblist_prev; 562 563 connections *fdwaitqueue; 563 564 -
trunk/src/buffer.c
r1445 r1465 1127 1127 if (!bp) return; 1128 1128 1129 FOREACH(bp, b, buffer_free(b));1129 ARRAY_STATIC_FREE(bp, buffer, b, buffer_free(b)); 1130 1130 1131 1131 free(bp); -
trunk/src/chunk.c
r1437 r1465 241 241 } 242 242 243 243 /* 244 * copy/steal max_len bytes from chunk chain. return total bytes copied/stolen. 245 * 246 */ 247 int chunkqueue_steal_chunks_len(chunkqueue *cq, chunk *c, size_t max_len) { 248 size_t total = 0; 249 off_t we_have = 0, we_want = 0; 250 buffer *b; 251 252 if (!cq || !c) return 0; 253 254 /* copy/steal chunks */ 255 for (; c && max_len > 0; c = c->next) { 256 /* skip empty chunks */ 257 if (c->mem->used == 0) continue; 258 259 we_have = c->mem->used - c->offset - 1; 260 if (we_have == 0) continue; 261 262 we_want = we_have < max_len ? we_have : max_len; 263 264 if (c->offset == 0 && we_have == we_want) { 265 /* steal whole chunk */ 266 chunkqueue_steal_chunk(cq, c); 267 } else { 268 /* copy unused data from chunk */ 269 b = chunkqueue_get_append_buffer(cq); 270 buffer_copy_string_len(b, c->mem->ptr + c->offset, we_want); 271 c->offset += we_want; 272 } 273 total += we_want; 274 max_len -= we_want; 275 } 276 return total; 277 } 278 279 int chunkqueue_skip(chunkqueue *cq, off_t skip) { 280 size_t total = 0; 281 off_t we_have = 0, we_want = 0; 282 chunk *c; 283 284 if (!cq) return 0; 285 286 /* consume chunks */ 287 for (c = cq->first; c && skip > 0; c = c->next) { 288 /* skip empty chunks */ 289 if (c->mem->used == 0) continue; 290 291 we_have = c->mem->used - c->offset - 1; 292 if (we_have == 0) continue; 293 294 we_want = we_have < skip ? we_have : skip; 295 296 c->offset += we_want; 297 total += we_want; 298 skip -= we_want; 299 } 300 return total; 301 } 302 244 303 int chunkqueue_append_buffer(chunkqueue *cq, buffer *mem) { 245 304 chunk *c; -
trunk/src/chunk.h
r1437 r1465 67 67 int chunkqueue_steal_tempfile(chunkqueue *cq, chunk *in); 68 68 int chunkqueue_steal_chunk(chunkqueue *cq, chunk *c); 69 int chunkqueue_steal_chunks_len(chunkqueue *cq, chunk *c, size_t max_len); 70 int chunkqueue_skip(chunkqueue *cq, off_t skip); 69 71 void chunkqueue_remove_empty_last_chunk(chunkqueue *cq); 70 72 -
trunk/src/connections.c
r1449 r1465 965 965 buffer_append_string(b, "\r\n"); 966 966 chunkqueue_append_buffer(cq, b); 967 len = b->used - 1; 967 968 968 969 buffer_free(b); 969 970 970 return 0;971 return len; 971 972 } 972 973 … … 978 979 chunk *c; 979 980 int is_chunked; 980 981 int we_have = 0; 982 983 /* no more data to encode. */ 984 if (out->is_closed) return 0; 981 985 /**/ 982 986 … … 989 993 if (c->mem->used == 0) continue; 990 994 991 http_chunk_append_len(out, c->mem->used - 1); 995 we_have = c->mem->used - c->offset - 1; 996 in->bytes_out += we_have; 997 if(we_have == 0) continue; 998 we_have += http_chunk_append_len(out, we_have); 992 999 chunkqueue_append_buffer(out, c->mem); 993 1000 c->offset = c->mem->used - 1; … … 996 1003 if (c->file.length == 0) continue; 997 1004 998 http_chunk_append_len(out, c->file.length); 999 chunkqueue_append_file(out, c->file.name, c->file.start, c->file.length); 1005 we_have = c->file.length; 1006 in->bytes_out += we_have; 1007 we_have += http_chunk_append_len(out, c->file.length); 1008 if(c->file.is_temp) { 1009 chunkqueue_steal_tempfile(out, c); 1010 } else { 1011 chunkqueue_append_file(out, c->file.name, c->file.start, c->file.length); 1012 } 1000 1013 1001 1014 c->offset = c->file.length; 1002 1015 break; 1016 case UNUSED_CHUNK: 1017 break; 1003 1018 } 1004 1019 chunkqueue_append_mem(out, "\r\n", 2 + 1); 1005 } 1006 if (in->is_closed) chunkqueue_append_mem(out, "0\r\n\r\n", 5 + 1); 1020 we_have += 2; 1021 out->bytes_in += we_have; 1022 } 1023 if (in->is_closed) { 1024 chunkqueue_append_mem(out, "0\r\n\r\n", 5 + 1); 1025 out->bytes_in += 5; 1026 } 1007 1027 } else { 1008 1028 for (c = in->first; c; c = c->next) { … … 1011 1031 if (c->mem->used == 0) continue; 1012 1032 1033 we_have = c->mem->used - c->offset - 1; 1034 in->bytes_out += we_have; 1035 if(we_have == 0) continue; 1013 1036 if (c->offset == 0) { 1014 1037 chunkqueue_steal_chunk(out, c); … … 1021 1044 if (c->file.length == 0) continue; 1022 1045 1023 chunkqueue_append_file(out, c->file.name, c->file.start, c->file.length); 1046 we_have = c->file.length; 1047 in->bytes_out += we_have; 1048 if(c->file.is_temp) { 1049 chunkqueue_steal_tempfile(out, c); 1050 } else { 1051 chunkqueue_append_file(out, c->file.name, c->file.start, c->file.length); 1052 } 1024 1053 1025 1054 c->offset = c->file.length; 1026 1055 break; 1027 } 1056 case UNUSED_CHUNK: 1057 break; 1058 } 1059 in->bytes_out += we_have; 1060 out->bytes_in += we_have; 1028 1061 } 1029 1062 } … … 1031 1064 chunkqueue_remove_finished_chunks(in); 1032 1065 1066 if (in->is_closed) { 1067 /* mark the output queue as finished. */ 1068 out->is_closed = 1; 1069 } 1033 1070 return 0; 1034 1071 } … … 1222 1259 1223 1260 connection_set_state(srv, con, CON_STATE_HANDLE_REQUEST_HEADER); 1261 1262 /* need to reset condition cache since request uri changed. */ 1263 config_cond_cache_reset(srv, con); 1224 1264 1225 1265 done = -1; … … 1353 1393 case NETWORK_STATUS_SUCCESS: 1354 1394 /* we send everything from the chunkqueue and the chunkqueue-sender signaled it is finished */ 1355 if (con->send ->is_closed) {1395 if (con->send_raw->is_closed) { 1356 1396 if (con->http_status == 100) { 1357 1397 /* send out the 100 Continue header and handle the request as normal afterwards */ … … 1362 1402 connection_set_state(srv, con, CON_STATE_RESPONSE_END); 1363 1403 } 1404 } else { 1405 /* still have data to send in send_raw queue */ 1406 fdevent_event_add(srv->ev, con->sock, FDEVENT_OUT); 1407 return HANDLER_WAIT_FOR_EVENT; 1364 1408 } 1365 1409 break; … … 1378 1422 return HANDLER_WAIT_FOR_EVENT; 1379 1423 case NETWORK_STATUS_INTERRUPTED: 1424 case NETWORK_STATUS_UNSET: 1380 1425 break; 1381 1426 } -
trunk/src/fdevent_freebsd_kqueue.c
r1349 r1465 118 118 size_t ndx; 119 119 120 for (ndx = 0; ndx < ev ->used; ndx++) {120 for (ndx = 0; ndx < event_count; ndx++) { 121 121 int events = 0, e; 122 122 -
trunk/src/http_resp.c
r1446 r1465 206 206 int last_token_id = 0; 207 207 208 if(!cq->first) return PARSE_NEED_MORE; 208 209 t.cq = cq; 209 210 t.c = cq->first; … … 251 252 http_resp_parserFree(pParser, free); 252 253 254 if (!buffer_is_empty(context.errmsg)) { 255 TRACE("parsing failed: %s", BUF_STR(context.errmsg)); 256 } 253 257 if (context.ok == 0) { 254 258 /* we are missing the some tokens */ … … 266 270 for (c = cq->first; c != t.c; c = c->next) { 267 271 c->offset = c->mem->used - 1; 272 cq->bytes_out += c->mem->used - 1; 268 273 } 269 274 270 275 c->offset = t.offset; 276 cq->bytes_out += t.offset; 271 277 272 278 ret = PARSE_SUCCESS; -
trunk/src/http_resp_parser.y
r1439 r1465 40 40 resp->status = strtol(ds->value->ptr, &err, 10); 41 41 42 if (*err != '\0' && *err != ' ' ) {42 if (*err != '\0' && *err != ' ' && *err != '\r') { 43 43 buffer_copy_string(ctx->errmsg, "expected a number: "); 44 44 buffer_append_string_buffer(ctx->errmsg, ds->value); -
trunk/src/joblist.c
r1349 r1465 8 8 int joblist_append(server *srv, connection *con) { 9 9 if (con->in_joblist) return 0; 10 con->in_joblist = 1; 10 11 11 12 if (srv->joblist->size == 0) { -
trunk/src/mod_auth.c
r1349 r1465 193 193 /* search auth-directives for path */ 194 194 for (k = 0; k < p->conf.auth_require->used; k++) { 195 buffer * req= p->conf.auth_require->data[k]->key;196 197 if ( req->used == 0) continue;198 if (con->uri.path->used < req->used) continue;195 buffer *auth_path = p->conf.auth_require->data[k]->key; 196 197 if (auth_path->used == 0) continue; 198 if (con->uri.path->used < auth_path->used) continue; 199 199 200 200 /* if we have a case-insensitive FS we have to lower-case the URI here too */ 201 201 202 202 if (con->conf.force_lowercase_filenames) { 203 if (0 == strncasecmp(con->uri.path->ptr, req->ptr, req->used - 1)) {203 if (0 == strncasecmp(con->uri.path->ptr, auth_path->ptr, auth_path->used - 1)) { 204 204 auth_required = 1; 205 205 break; 206 206 } 207 207 } else { 208 if (0 == strncmp(con->uri.path->ptr, req->ptr, req->used - 1)) {208 if (0 == strncmp(con->uri.path->ptr, auth_path->ptr, auth_path->used - 1)) { 209 209 auth_required = 1; 210 210 break; -
trunk/src/mod_indexfile.c
r1460 r1465 10 10 11 11 #include "plugin.h" 12 13 #include "configfile.h" 12 14 13 15 #include "stat_cache.h" -
trunk/src/mod_proxy_backend_fastcgi.c
r1418 r1465 5 5 #include "inet_ntop_cache.h" 6 6 #include "mod_proxy_core.h" 7 #include "mod_proxy_core_protocol.h" 7 8 #include "buffer.h" 8 9 #include "log.h" 9 10 #include "fastcgi.h" 10 11 #include "array.h" 12 13 #define CORE_PLUGIN "mod_proxy_core" 14 15 typedef struct { 16 PLUGIN_DATA; 17 18 proxy_protocol *protocol; 19 } protocol_plugin_data; 11 20 12 21 /** … … 20 29 #endif 21 30
