Changeset 1611
- Timestamp:
- 07/07/08 09:07:05 (2 months ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/connection.c (modified) (2 diffs)
- cherokee/trunk/cherokee/connection.h (modified) (1 diff)
- cherokee/trunk/cherokee/handler_cgi_base.c (modified) (2 diffs)
- cherokee/trunk/cherokee/handler_common.c (modified) (4 diffs)
- cherokee/trunk/cherokee/handler_dirlist.c (modified) (1 diff)
- cherokee/trunk/cherokee/handler_file.c (modified) (2 diffs)
- cherokee/trunk/cherokee/handler_phpcgi.c (modified) (1 diff)
- cherokee/trunk/cherokee/rule_directory.c (modified) (5 diffs)
- cherokee/trunk/cherokee/thread.c (modified) (4 diffs)
- cherokee/trunk/cherokee/util.c (modified) (1 diff)
- cherokee/trunk/cherokee/util.h (modified) (1 diff)
- cherokee/trunk/cherokee/virtual_server.c (modified) (3 diffs)
- cherokee/trunk/cherokee/virtual_server.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r1610 r1611 1 1 2008-07-07 Alvaro Lopez Ortega <alvaro@alobbs.com> 2 3 * cherokee/connection.c: Added cherokee_connection_print(). It is 4 a function that is only called from the TRACE_CONN() macro. It 5 prints the connection object property values within the TRACE log. 6 7 * cherokee/thread.c: Moves phase_to_str() to cherokee/connection.c 8 as cherokee_connection_get_phase_str(). 9 10 * cherokee/handler_cgi_base.c, cherokee/handler_file.c, 11 cherokee/handler_phpcgi.c: Fixed to work with the previous 12 cherokee_fix_dirpath() change. Now we are certain about whether a 13 path ends with a slash (it does not). 14 15 * cherokee/virtual_server.c: Added cherokee_fix_dirpath() calls 16 where needed. 17 18 * cherokee/virtual_server.c (cherokee_virtual_server_set_documentroot): 19 removed. 20 21 * cherokee/util.c, cherokee/util.h: Added cherokee_fix_dirpath(). 2 22 3 23 * cherokee/iocache.c (iocache_entry_maybe_update_mmap): cherokee/trunk/cherokee/connection.c
r1607 r1611 1914 1914 { 1915 1915 cherokee_buffer_t *buf = &conn->self_trace; 1916 1916 const char *phase; 1917 1918 phase = cherokee_connection_get_phase_str (conn); 1919 1917 1920 cherokee_buffer_clean (buf); 1918 1921 cherokee_buffer_add_va (buf, "Connection %p info\n", conn); 1919 1922 1920 #define print_buf(title,name) \ 1921 cherokee_buffer_add_va (buf, "\t| %s: '%s' (%d)\n", title, \ 1922 conn->name.buf ? conn->name.buf : "NULL", \ 1923 conn->name.len); 1924 #define print_int(title,name) \ 1925 cherokee_buffer_add_va (buf, "\t| % 20s: %d\n", title, conn->name); 1926 1927 print_buf (" Request", request); 1928 print_buf (" Web Directory", web_directory); 1929 print_buf ("Local Directory", local_directory); 1930 print_buf (" Pathinfo", pathinfo); 1931 print_buf (" User Dir", userdir); 1932 print_buf (" Query string", query_string); 1933 print_buf (" Host", host); 1934 print_buf (" Redirect", redirect); 1935 print_int (" Keepalive", keepalive); 1923 #define print_buf(title,name) \ 1924 cherokee_buffer_add_va (buf, "\t| %s: '%s' (%d)\n", title, \ 1925 (name)->buf ? (name)->buf : "", \ 1926 (name)->len); 1927 #define print_cbuf(title,name) \ 1928 print_buf(title, &conn->name) 1929 1930 #define print_cint(title,name) \ 1931 cherokee_buffer_add_va (buf, "\t| %s: %d\n", title, conn->name); 1932 1933 #define print_str(title,name) \ 1934 cherokee_buffer_add_va (buf, "\t| %s: %s\n", title, name); 1935 1936 #define print_add(str) \ 1937 cherokee_buffer_add_str (buf, str) 1938 1939 print_cbuf (" Request", request); 1940 print_cbuf (" Web Directory", web_directory); 1941 print_cbuf ("Local Directory", local_directory); 1942 print_cbuf (" Pathinfo", pathinfo); 1943 print_cbuf (" User Dir", userdir); 1944 print_cbuf (" Query string", query_string); 1945 print_cbuf (" Host", host); 1946 print_cbuf (" Redirect", redirect); 1947 print_cint (" Keepalive", keepalive); 1948 print_str (" Phase", phase); 1949 print_cint (" Range start", range_start); 1950 print_cint (" Range end", range_end); 1951 1952 /* Options bit fields 1953 */ 1954 print_add ("\t| Option bits:"); 1955 if (conn->options & conn_op_log_at_end) 1956 print_add (" log_at_end"); 1957 if (conn->options & conn_op_root_index) 1958 print_add (" root_index"); 1959 if (conn->options & conn_op_tcp_cork) 1960 print_add (" tcp_cork"); 1961 if (conn->options & conn_op_document_root) 1962 print_add (" document_root"); 1963 print_add ("\n"); 1936 1964 1937 1965 #undef print_buf 1938 #undef print_int 1966 #undef print_cbuf 1967 #undef print_cint 1968 #undef print_str 1969 #undef print_add 1939 1970 1940 1971 cherokee_buffer_add_str (buf, "\t\\_\n"); … … 1942 1973 } 1943 1974 #endif 1975 1976 #ifdef TRACE_ENABLED 1977 char * 1978 cherokee_connection_get_phase_str (cherokee_connection_t *conn) 1979 { 1980 switch (conn->phase) { 1981 case phase_nothing: return "Nothing"; 1982 case phase_switching_headers: return "Switch headers"; 1983 case phase_tls_handshake: return "TLS handshake"; 1984 case phase_reading_header: return "Reading header"; 1985 case phase_processing_header: return "Processing header"; 1986 case phase_read_post: return "Read POST"; 1987 case phase_setup_connection: return "Setup connection"; 1988 case phase_init: return "Init connection"; 1989 case phase_add_headers: return "Add headers"; 1990 case phase_send_headers: return "Send headers"; 1991 case phase_steping: return "Step"; 1992 case phase_shutdown: return "Shutdown connection"; 1993 case phase_lingering: return "Lingering close"; 1994 default: 1995 SHOULDNT_HAPPEN; 1996 } 1997 return NULL; 1998 } 1999 #endif cherokee/trunk/cherokee/connection.h
r1606 r1611 42 42 /* Public methods 43 43 */ 44 ret_t cherokee_connection_set_cork (cherokee_connection_t *conn, cherokee_boolean_t enable); 45 ret_t cherokee_connection_parse_args (cherokee_connection_t *conn); 44 ret_t cherokee_connection_set_cork (cherokee_connection_t *conn, cherokee_boolean_t enable); 45 ret_t cherokee_connection_parse_args (cherokee_connection_t *conn); 46 char *cherokee_connection_get_phase_str (cherokee_connection_t *conn); 46 47 47 48 CHEROKEE_END_DECLS cherokee/trunk/cherokee/handler_cgi_base.c
r1583 r1611 633 633 local_len = conn->local_directory.len; 634 634 635 /* It is going to concatenate two paths like: local_directory 636 * = "/usr/share/cgi-bin/", and request = "/thing.cgi", so 637 * there would be two slashes in the middle of the request. 638 */ 639 if (req_len > 0) { 640 cherokee_buffer_add (&conn->local_directory, 641 conn->request.buf + 1, 642 conn->request.len - 1); 643 } 635 cherokee_buffer_add_buffer (&conn->local_directory, &conn->request); 644 636 645 637 /* Build the pathinfo string … … 1034 1026 1035 1027 ret_t 1036 cherokee_handler_cgi_base_split_pathinfo (cherokee_handler_cgi_base_t *cgi, cherokee_buffer_t *buf, int init_pos, int allow_dirs) 1028 cherokee_handler_cgi_base_split_pathinfo (cherokee_handler_cgi_base_t *cgi, 1029 cherokee_buffer_t *buf, 1030 int init_pos, 1031 int allow_dirs) 1037 1032 { 1038 1033 ret_t ret; cherokee/trunk/cherokee/handler_common.c
r1286 r1611 173 173 cherokee_connection_t *conn = CONN(cnt); 174 174 175 TRACE_CONN(conn); 176 175 177 /* Check some properties 176 178 */ … … 224 226 */ 225 227 cherokee_buffer_clean (&conn->local_directory); 226 227 228 cherokee_iocache_mmap_release (iocache, file); 229 230 TRACE_CONN(conn); 228 231 return ret_eagain; 229 232 } … … 303 306 304 307 BIT_SET (conn->options, conn_op_root_index); 308 309 TRACE_CONN(conn); 305 310 return ret_eagain; 306 311 } … … 326 331 /* Add the index file to the request and clean up 327 332 */ 328 cherokee_buffer_drop_endding (&conn->local_directory, conn->request.len); 329 cherokee_buffer_add (&conn->request, index, index_len); 330 333 cherokee_buffer_drop_endding (&conn->local_directory, conn->request.len); 334 cherokee_buffer_add (&conn->request, index, index_len); 335 336 TRACE_CONN(conn); 331 337 return ret_eagain; 332 338 } cherokee/trunk/cherokee/handler_dirlist.c
r1608 r1611 357 357 CHEROKEE_NEW_STRUCT (n, handler_dirlist); 358 358 359 TRACE_CONN(cnt); 360 359 361 /* Init the base class object 360 362 */ cherokee/trunk/cherokee/handler_file.c
r1479 r1611 98 98 { 99 99 CHEROKEE_NEW_STRUCT (n, handler_file); 100 101 TRACE_CONN(cnt); 100 102 101 103 /* Init the base class object … … 524 526 /* Build the local file path 525 527 */ 526 if (conn->request.len > 1) { 527 cherokee_buffer_add (&conn->local_directory, conn->request.buf+1, conn->request.len-1); 528 } 529 528 cherokee_buffer_add_buffer (&conn->local_directory, &conn->request); 530 529 ret = cherokee_handler_file_custom_init (fhdl, &conn->local_directory); 531 530 532 531 /* Undo the local directory 533 532 */ 534 if (conn->request.len > 1) { 535 cherokee_buffer_drop_endding (&conn->local_directory, conn->request.len); 536 } 537 533 cherokee_buffer_drop_endding (&conn->local_directory, conn->request.len); 538 534 return ret; 539 535 } cherokee/trunk/cherokee/handler_phpcgi.c
r1131 r1611 207 207 */ 208 208 if (cgi->param.len <= 0) { 209 cherokee_buffer_add (&cgi->param, ld->buf, ld->len - 1);209 cherokee_buffer_add_buffer (&cgi->param, ld); 210 210 cherokee_buffer_add_buffer (&cgi->param, &conn->request); 211 cherokee_handler_cgi_base_split_pathinfo (cgi, &cgi->param, ld->len + 1, false);211 cherokee_handler_cgi_base_split_pathinfo (cgi, &cgi->param, ld->len, false); 212 212 } 213 213 cherokee/trunk/cherokee/rule_directory.c
r1605 r1611 40 40 */ 41 41 if (conn->request.len < rule->directory.len) { 42 TRACE(ENTRIES, "Match directory: rule=%s conn=%s: (shorter) ret_not_found\n",42 TRACE(ENTRIES, "Match directory: rule=%s req=%s: (shorter) ret_not_found\n", 43 43 rule->directory.buf, conn->request.buf); 44 44 return ret_not_found; … … 48 48 */ 49 49 if (strncmp (rule->directory.buf, conn->request.buf, rule->directory.len) != 0) { 50 TRACE(ENTRIES, "Match directory: rule=%s conn=%s: (str) ret_not_found\n",50 TRACE(ENTRIES, "Match directory: rule=%s req=%s: (str) ret_not_found\n", 51 51 rule->directory.buf, conn->request.buf); 52 52 return ret_not_found; … … 67 67 if ((conn->request.len > 1) && 68 68 (cherokee_buffer_end_char (&conn->request) != '/') && 69 (cherokee_buffer_cmp_buf (&conn->request, & conn->web_directory) == 0))69 (cherokee_buffer_cmp_buf (&conn->request, &rule->directory) == 0)) 70 70 { 71 71 cherokee_buffer_ensure_size (&conn->redirect, conn->request.len + 4); … … 84 84 } 85 85 86 TRACE(ENTRIES, "Match! rule=%s conn=%s web_directory=%s: ret_ok\n",86 TRACE(ENTRIES, "Match! rule=%s req=%s web_directory=%s: ret_ok\n", 87 87 rule->directory.buf, conn->request.buf, conn->web_directory.buf); 88 88 … … 107 107 } 108 108 109 cherokee_fix_dirpath (&rule->directory); 109 110 return ret_ok; 110 111 } cherokee/trunk/cherokee/thread.c
r1566 r1611 49 49 50 50 51 #ifdef TRACE_ENABLED52 static char *53 phase_to_str (cherokee_connection_phase_t phase)54 {55 switch (phase) {56 case phase_nothing: return "Nothing";57 case phase_switching_headers: return "Switch headers";58 case phase_tls_handshake: return "TLS handshake";59 case phase_reading_header: return "Reading header";60 case phase_processing_header: return "Processing header";61 case phase_read_post: return "Read POST";62 case phase_setup_connection: return "Setup connection";63 case phase_init: return "Init connection";64 case phase_add_headers: return "Add headers";65 case phase_send_headers: return "Send headers";66 case phase_steping: return "Step";67 case phase_shutdown: return "Shutdown connection";68 case phase_lingering: return "Lingering close";69 default:70 SHOULDNT_HAPPEN;71 }72 return NULL;73 }74 #endif75 76 51 static void 77 52 update_bogo_now_internal (cherokee_thread_t *thd) … … 644 619 645 620 TRACE (ENTRIES, "thread (%p) processing conn (%p), phase %d '%s'\n", 646 thd, conn, conn->phase, phase_to_str(conn->phase));621 thd, conn, conn->phase, cherokee_connection_get_phase_str (conn)); 647 622 648 623 /* Has the connection been too much time w/o any work … … 688 663 conn->timeout = thd->bogo_now + srv->timeout; 689 664 690 TRACE (ENTRIES, "conn on phase n=%d: %s\n", conn->phase, phase_to_str(conn->phase)); 665 TRACE (ENTRIES, "conn on phase n=%d: %s\n", 666 conn->phase, cherokee_connection_get_phase_str (conn)); 691 667 692 668 /* Phases … … 911 887 cherokee_rule_list_t *rules; 912 888 cherokee_boolean_t is_userdir; 913 889 914 890 TRACE (ENTRIES, "Setup connection begins: request=\"%s\"\n", conn->request.buf); 915 891 TRACE_CONN(conn); 892 916 893 /* Turn the connection in write mode 917 894 */ cherokee/trunk/cherokee/util.c
r1587 r1611 1289 1289 fflush (stdout); 1290 1290 } 1291 1292 1293 ret_t 1294 cherokee_fix_dirpath (cherokee_buffer_t *buf) 1295 { 1296 while (cherokee_buffer_is_endding(buf, '/')) { 1297 cherokee_buffer_drop_endding (buf, 1); 1298 } 1299 1300 return ret_ok; 1301 } cherokee/trunk/cherokee/util.h
r1571 r1611 89 89 size_t cherokee_strlcat (char *dst, const char *src, size_t siz); 90 90 int cherokee_estimate_va_length (char *format, va_list ap); 91 ret_t cherokee_fix_dirpath (cherokee_buffer_t *buf); 91 92 92 93 /* Time management functions cherokee/trunk/cherokee/virtual_server.c
r1501 r1611 340 340 341 341 342 ret_t343 cherokee_virtual_server_set_documentroot (cherokee_virtual_server_t *vserver, const char *documentroot)344 {345 cherokee_buffer_clean (&vserver->root);346 cherokee_buffer_add (&vserver->root, documentroot, strlen(documentroot));347 348 return ret_ok;349 }350 351 352 342 static ret_t 353 343 add_directory_index (char *index, void *data) … … 402 392 cherokee_buffer_clean (entry->document_root); 403 393 404 TRACE(ENTRIES, "DocumentRoot: %s\n", tmp->buf);405 394 cherokee_buffer_add_buffer (entry->document_root, tmp); 395 cherokee_fix_dirpath (entry->document_root); 396 397 TRACE(ENTRIES, "DocumentRoot: %s\n", entry->document_root->buf); 406 398 407 399 } else if (equal_buf_str (&conf->key, "handler")) { … … 753 745 return ret; 754 746 755 ret = cherokee_virtual_server_set_documentroot (vserver, (const char *)tmp->buf); 756 if (ret != ret_ok) { 757 PRINT_MSG ("ERROR: Virtual server: Error setting DocumentRoot: '%s'\n", tmp->buf); 758 return ret_error; 759 } 747 cherokee_buffer_clean (&vserver->root); 748 cherokee_buffer_add_buffer (&vserver->root, tmp); 749 cherokee_fix_dirpath (&vserver->root); 760 750 761 751 } else if (equal_buf_str (&conf->key, "user_dir")) { cherokee/trunk/cherokee/virtual_server.h
r1425 r1611 114 114 void cherokee_virtual_server_add_tx (cherokee_virtual_server_t *vserver, size_t tx); 115 115 116 /* Configuration117 */118 ret_t cherokee_virtual_server_set_documentroot (cherokee_virtual_server_t *vserver, const char *documentroot);119 120 116 #endif /* CHEROKEE_VIRTUAL_SERVER_H */