Changeset 1611

Show
Ignore:
Timestamp:
07/07/08 09:07:05 (2 months ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/ChangeLog

    r1610 r1611  
    112008-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(). 
    222 
    323        * cherokee/iocache.c (iocache_entry_maybe_update_mmap): 
  • cherokee/trunk/cherokee/connection.c

    r1607 r1611  
    19141914{ 
    19151915        cherokee_buffer_t *buf = &conn->self_trace; 
    1916          
     1916        const char        *phase; 
     1917 
     1918        phase = cherokee_connection_get_phase_str (conn); 
     1919 
    19171920        cherokee_buffer_clean (buf); 
    19181921        cherokee_buffer_add_va (buf, "Connection %p info\n", conn); 
    19191922 
    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"); 
    19361964 
    19371965#undef print_buf 
    1938 #undef print_int 
     1966#undef print_cbuf 
     1967#undef print_cint 
     1968#undef print_str 
     1969#undef print_add 
    19391970 
    19401971        cherokee_buffer_add_str (buf, "\t\\_\n"); 
     
    19421973} 
    19431974#endif 
     1975 
     1976#ifdef TRACE_ENABLED 
     1977char * 
     1978cherokee_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  
    4242/* Public methods 
    4343 */ 
    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); 
     44ret_t  cherokee_connection_set_cork      (cherokee_connection_t *conn, cherokee_boolean_t enable); 
     45ret_t  cherokee_connection_parse_args    (cherokee_connection_t *conn); 
     46char  *cherokee_connection_get_phase_str (cherokee_connection_t *conn); 
    4647 
    4748CHEROKEE_END_DECLS 
  • cherokee/trunk/cherokee/handler_cgi_base.c

    r1583 r1611  
    633633        local_len    = conn->local_directory.len; 
    634634 
    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); 
    644636 
    645637        /* Build the pathinfo string 
     
    10341026 
    10351027ret_t 
    1036 cherokee_handler_cgi_base_split_pathinfo (cherokee_handler_cgi_base_t *cgi, cherokee_buffer_t *buf, int init_pos, int allow_dirs)  
     1028cherokee_handler_cgi_base_split_pathinfo (cherokee_handler_cgi_base_t *cgi,  
     1029                                          cherokee_buffer_t           *buf,  
     1030                                          int                          init_pos,  
     1031                                          int                          allow_dirs)  
    10371032{ 
    10381033        ret_t                  ret; 
  • cherokee/trunk/cherokee/handler_common.c

    r1286 r1611  
    173173        cherokee_connection_t    *conn        = CONN(cnt); 
    174174 
     175        TRACE_CONN(conn); 
     176 
    175177        /* Check some properties 
    176178         */ 
     
    224226                 */ 
    225227                cherokee_buffer_clean (&conn->local_directory); 
    226  
    227228                cherokee_iocache_mmap_release (iocache, file); 
     229 
     230                TRACE_CONN(conn); 
    228231                return ret_eagain; 
    229232        }        
     
    303306 
    304307                                BIT_SET (conn->options, conn_op_root_index); 
     308 
     309                                TRACE_CONN(conn); 
    305310                                return ret_eagain; 
    306311                        } 
     
    326331                        /* Add the index file to the request and clean up 
    327332                         */ 
    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); 
    331337                        return ret_eagain; 
    332338                } 
  • cherokee/trunk/cherokee/handler_dirlist.c

    r1608 r1611  
    357357        CHEROKEE_NEW_STRUCT (n, handler_dirlist); 
    358358         
     359        TRACE_CONN(cnt); 
     360 
    359361        /* Init the base class object 
    360362         */ 
  • cherokee/trunk/cherokee/handler_file.c

    r1479 r1611  
    9898{ 
    9999        CHEROKEE_NEW_STRUCT (n, handler_file); 
     100 
     101        TRACE_CONN(cnt); 
    100102         
    101103        /* Init the base class object 
     
    524526        /* Build the local file path 
    525527         */ 
    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); 
    530529        ret = cherokee_handler_file_custom_init (fhdl, &conn->local_directory); 
    531530 
    532531        /* Undo the local directory 
    533532         */ 
    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);        
    538534        return ret; 
    539535} 
  • cherokee/trunk/cherokee/handler_phpcgi.c

    r1131 r1611  
    207207        */ 
    208208        if (cgi->param.len <= 0) {               
    209                 cherokee_buffer_add (&cgi->param, ld->buf, ld->len - 1); 
     209                cherokee_buffer_add_buffer (&cgi->param, ld); 
    210210                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); 
    212212        } 
    213213         
  • cherokee/trunk/cherokee/rule_directory.c

    r1605 r1611  
    4040         */ 
    4141        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", 
    4343                      rule->directory.buf, conn->request.buf); 
    4444                return ret_not_found; 
     
    4848         */ 
    4949        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", 
    5151                      rule->directory.buf, conn->request.buf); 
    5252                return ret_not_found; 
     
    6767        if ((conn->request.len > 1) && 
    6868            (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)) 
    7070        { 
    7171                cherokee_buffer_ensure_size (&conn->redirect, conn->request.len + 4); 
     
    8484        } 
    8585 
    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", 
    8787              rule->directory.buf, conn->request.buf, conn->web_directory.buf); 
    8888 
     
    107107        } 
    108108 
     109        cherokee_fix_dirpath (&rule->directory); 
    109110        return ret_ok; 
    110111} 
  • cherokee/trunk/cherokee/thread.c

    r1566 r1611  
    4949 
    5050 
    51 #ifdef TRACE_ENABLED 
    52 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 #endif 
    75  
    7651static void 
    7752update_bogo_now_internal (cherokee_thread_t *thd) 
     
    644619 
    645620                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)); 
    647622 
    648623                /* Has the connection been too much time w/o any work 
     
    688663                conn->timeout = thd->bogo_now + srv->timeout; 
    689664 
    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)); 
    691667 
    692668                /* Phases 
     
    911887                        cherokee_rule_list_t    *rules; 
    912888                        cherokee_boolean_t       is_userdir; 
    913  
     889                         
    914890                        TRACE (ENTRIES, "Setup connection begins: request=\"%s\"\n", conn->request.buf); 
    915  
     891                        TRACE_CONN(conn); 
     892                      
    916893                        /* Turn the connection in write mode 
    917894                         */ 
  • cherokee/trunk/cherokee/util.c

    r1587 r1611  
    12891289        fflush (stdout); 
    12901290} 
     1291 
     1292 
     1293ret_t 
     1294cherokee_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  
    8989size_t  cherokee_strlcat            (char *dst, const char *src, size_t siz); 
    9090int     cherokee_estimate_va_length (char *format, va_list ap); 
     91ret_t   cherokee_fix_dirpath        (cherokee_buffer_t *buf); 
    9192 
    9293/* Time management functions 
  • cherokee/trunk/cherokee/virtual_server.c

    r1501 r1611  
    340340 
    341341 
    342 ret_t  
    343 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  
    352342static ret_t  
    353343add_directory_index (char *index, void *data) 
     
    402392                        cherokee_buffer_clean (entry->document_root); 
    403393 
    404                 TRACE(ENTRIES, "DocumentRoot: %s\n", tmp->buf); 
    405394                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); 
    406398 
    407399        } else if (equal_buf_str (&conf->key, "handler")) { 
     
    753745                        return ret; 
    754746                 
    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); 
    760750 
    761751        } else if (equal_buf_str (&conf->key, "user_dir")) { 
  • cherokee/trunk/cherokee/virtual_server.h

    r1425 r1611  
    114114void  cherokee_virtual_server_add_tx    (cherokee_virtual_server_t *vserver, size_t tx); 
    115115 
    116 /* Configuration 
    117  */ 
    118 ret_t cherokee_virtual_server_set_documentroot (cherokee_virtual_server_t *vserver, const char *documentroot); 
    119  
    120116#endif /* CHEROKEE_VIRTUAL_SERVER_H */