Changeset 639

Show
Ignore:
Timestamp:
02/04/07 22:21:29 (2 years ago)
Author:
alo
Message:

--

Files:

Legend:

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

    r638 r639  
     12007-02-02  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
     2 
     3        * qa/run-tests.py: Fixed to work just with "-v" (without 
     4        specifying with valgrind tool it should use). 
     5 
     6        * cherokee/handler_file.c (cherokee_handler_file_step): Updated to 
     7        the latest conn->option and tcp_cork changes. 
     8 
     9        * cherokee/connection.h, 
     10        cherokee/connection.c (cherokee_connection_set_cork): Now the 
     11        "enable" parameter is cherokee_boolean_t rather than int. 
     12 
     13        * cherokee/connection-protected.h: Added new enum type 
     14        cherokee_connection_options_t and a new property "options" to the 
     15        connection class. 
     16         
     17 
     18        * cherokee/handler_common.c (cherokee_handler_common_new): If the 
     19        connection needs to be redirected/reprocessed, it copys the 
     20        request to the request_original and sets a flag if it's a 
     21        redirection to a index file starting by / (fullpath index file). 
     22         
     23        * cherokee/handler_cgi_base.c (cherokee_handler_cgi_base_build_basic_env): 
     24        Checks the connection options. If it has been redirected from a 
     25        "common" handler and targets a fullpath index, it seems to need to 
     26        use the original request as the REQUEST_URI. 
     27 
     28        * cherokee/macros.h (BIT_SET, BIT_UNSET): Added new macros to ease 
     29        bit masks manupulation. 
     30         
     31        * cherokee/connection-protected.h: log_at_end and tcp_cork 
     32        properties have been removed. Now they're bits in the options 
     33        entry. 
     34 
     35        * cherokee/connection.c (cherokee_connection_log_or_delay, 
     36        cherokee_connection_log_delayed): Rewritten using the option 
     37        property. 
     38 
    1392007-01-30  A.D.F  <adefacc@tin.it> 
    240 
  • cherokee/trunk/cherokee/buffer.h

    r624 r639  
    102102ret_t cherokee_buffer_ensure_size        (cherokee_buffer_t  *buf, size_t size); 
    103103 
    104 int   cherokee_buffer_is_endding         (cherokee_buffer_t  *buf, char c); 
    105 char  cherokee_buffer_end_char           (cherokee_buffer_t  *buf); 
     104int    cherokee_buffer_is_endding        (cherokee_buffer_t  *buf, char c); 
     105char  cherokee_buffer_end_char          (cherokee_buffer_t  *buf); 
    106106size_t cherokee_buffer_cnt_spn           (cherokee_buffer_t  *buf, int offset, char *str); 
    107107size_t cherokee_buffer_cnt_cspn          (cherokee_buffer_t  *buf, int offset, char *str); 
  • cherokee/trunk/cherokee/connection-protected.h

    r637 r639  
    8282} cherokee_connection_phase_t; 
    8383 
     84typedef enum { 
     85        conn_op_nothing    = 0, 
     86        conn_op_log_at_end = 1, 
     87        conn_op_root_index = 1 << 1, 
     88        conn_op_tcp_cork   = 1 << 2 
     89} cherokee_connection_options_t; 
     90 
    8491 
    8592struct cherokee_connection { 
     
    99106         */ 
    100107        cherokee_socket_t             socket; 
    101         int                           tcp_cork
     108        cherokee_http_upgrade_t       upgrade
    102109                 
    103110        cherokee_logger_t            *logger_ref; 
    104         int                           log_at_end; 
    105          
    106111        cherokee_handler_t           *handler; 
    107         cherokee_http_upgrade_t       upgrade
     112        cherokee_connection_options_t options
    108113         
    109114        /* Buffers 
  • cherokee/trunk/cherokee/connection.c

    r637 r639  
    9292        INIT_LIST_HEAD(&n->list_entry); 
    9393 
    94         n->tcp_cork          = 0; 
    9594        n->error_code        = http_ok; 
    9695        n->phase             = phase_reading_header; 
     
    9998        n->req_auth_type     = http_auth_nothing; 
    10099        n->upgrade           = http_upgrade_nothing; 
     100        n->options           = conn_op_nothing; 
    101101        n->handler           = NULL;  
    102102        n->encoder           = NULL; 
     
    106106        n->range_end         = 0; 
    107107        n->vserver           = NULL; 
    108         n->log_at_end        = 1; 
    109108        n->arguments         = NULL; 
    110109        n->realm_ref         = NULL; 
     
    228227        conn->req_auth_type     = http_auth_nothing; 
    229228        conn->upgrade           = http_upgrade_nothing; 
     229        conn->options           = conn_op_nothing; 
    230230        conn->error_code        = http_ok; 
    231231        conn->range_start       = 0; 
    232232        conn->range_end         = 0; 
    233233        conn->logger_ref        = NULL; 
    234         conn->tcp_cork          = 0; 
    235         conn->log_at_end        = 1; 
    236234        conn->realm_ref         = NULL; 
    237235        conn->mmaped            = NULL; 
     
    735733 
    736734ret_t  
    737 cherokee_connection_set_cork (cherokee_connection_t *conn, int enable) 
     735cherokee_connection_set_cork (cherokee_connection_t *conn, cherokee_boolean_t enable) 
    738736{ 
    739737        int on = 0; 
     
    754752        } 
    755753 
    756         conn->tcp_cork = enable
     754        BIT_SET (conn->options, conn_op_tcp_cork)
    757755#endif 
    758756 
     
    18881886cherokee_connection_log_or_delay (cherokee_connection_t *conn) 
    18891887{ 
    1890         ret_t ret = ret_ok; 
    1891          
    1892         if (conn->handler == NULL) { 
    1893                 conn->log_at_end = 0; 
     1888        ret_t              ret; 
     1889        cherokee_boolean_t at_end; 
     1890 
     1891        /* Check whether it should log at end or not.. 
     1892         */ 
     1893        if (conn->handler == NULL) 
     1894                at_end = true; 
     1895        else 
     1896                at_end = ! HANDLER_SUPPORT_LENGTH(conn->handler); 
     1897         
     1898        /* Set the option bit mask 
     1899         */ 
     1900        if (at_end) 
     1901                BIT_SET (conn->options, conn_op_log_at_end); 
     1902        else  
     1903                BIT_UNSET (conn->options, conn_op_log_at_end); 
     1904 
     1905        /* Return if there is no logger or has to log_at_end 
     1906         */ 
     1907        if (conn->logger_ref == NULL) 
     1908                return ret_ok; 
     1909        if (conn->options & conn_op_log_at_end) 
     1910                return ret_ok; 
     1911 
     1912        /* Log it 
     1913         */ 
     1914        if (http_type_400(conn->error_code) || 
     1915            http_type_500(conn->error_code)) { 
     1916                ret = cherokee_logger_write_error (conn->logger_ref, conn); 
    18941917        } else { 
    1895                 conn->log_at_end = ! HANDLER_SUPPORT_LENGTH(conn->handler); 
    1896         } 
    1897  
    1898         if (conn->log_at_end == 0) { 
    1899                 if (conn->logger_ref != NULL) { 
    1900                         if (http_type_400(conn->error_code) || 
    1901                             http_type_500(conn->error_code)) { 
    1902                                 ret = cherokee_logger_write_error (conn->logger_ref, conn); 
    1903                         } else { 
    1904                                 ret = cherokee_logger_write_access (conn->logger_ref, conn); 
    1905                         } 
    1906                         conn->log_at_end = 0; 
    1907                 } 
     1918                ret = cherokee_logger_write_access (conn->logger_ref, conn); 
    19081919        } 
    19091920 
     
    19151926cherokee_connection_log_delayed (cherokee_connection_t *conn) 
    19161927{ 
    1917         ret_t ret = ret_ok; 
    1918  
    1919         if ((conn->log_at_end) && (conn->logger_ref)) { 
    1920                 ret = cherokee_logger_write_access (conn->logger_ref, conn); 
    1921                 conn->log_at_end = false; 
    1922         } 
    1923  
    1924         return ret; 
     1928        ret_t ret; 
     1929 
     1930        /* Check whether if needs to log now of not 
     1931         */ 
     1932        if (conn->logger_ref == NULL) 
     1933                return ret_ok; 
     1934        if (! (conn->options & conn_op_log_at_end)) 
     1935                return ret_ok; 
     1936 
     1937        /* Log it 
     1938         */ 
     1939        BIT_UNSET (conn->options, conn_op_log_at_end); 
     1940 
     1941        ret = cherokee_logger_write_access (conn->logger_ref, conn); 
     1942        if (unlikely (ret != ret_ok)) return ret; 
     1943 
     1944        return ret_ok; 
    19251945} 
    19261946 
  • cherokee/trunk/cherokee/connection.h

    r597 r639  
    4242/* Public methods 
    4343 */ 
    44 ret_t cherokee_connection_set_cork       (cherokee_connection_t *cnt, int enable); 
     44ret_t cherokee_connection_set_cork       (cherokee_connection_t *cnt, cherokee_boolean_t enable); 
    4545ret_t cherokee_connection_parse_args     (cherokee_connection_t *cnt); 
    4646 
  • cherokee/trunk/cherokee/handler_cgi_base.c

    r638 r639  
    345345                set_env (cgi, "PATH_INFO", "", 0); 
    346346 
    347         /* Set REQUEST_URI  
    348          */ 
    349         { 
    350                 cherokee_handler_cgi_base_props_t *cgi_props = HANDLER_CGI_BASE_PROPS(cgi);  
    351                 printf ("script_name %s\n", cgi_props->script_alias.buf); 
    352         } 
    353  
     347        /* Set REQUEST_URI: 
     348         * 
     349         * Use request + query_string unless the connections has been 
     350         * redirected from common and targets a full path index file.  
     351         */ 
    354352        cherokee_buffer_clean (tmp); 
    355 //      cherokee_header_copy_request_w_args (&conn->header, tmp); 
    356         cherokee_buffer_add_buffer (tmp, &conn->request); 
    357         if (! cherokee_buffer_is_empty (&conn->query_string)) { 
    358                 cherokee_buffer_add_char (tmp, '?'); 
    359                 cherokee_buffer_add_buffer (tmp, &conn->query_string); 
     353 
     354        if (conn->options & conn_op_root_index) { 
     355                cherokee_header_copy_request_w_args (&conn->header, tmp); 
     356        }  
     357        else { 
     358                cherokee_buffer_add_buffer (tmp, &conn->request); 
     359                if (! cherokee_buffer_is_empty (&conn->query_string)) { 
     360                        cherokee_buffer_add_char (tmp, '?'); 
     361                        cherokee_buffer_add_buffer (tmp, &conn->query_string); 
     362                } 
    360363        } 
    361364        set_env (cgi, "REQUEST_URI", tmp->buf, tmp->len); 
  • cherokee/trunk/cherokee/handler_common.c

    r606 r639  
    283283                                 */ 
    284284                                cherokee_buffer_clean (&conn->local_directory); 
     285                                cherokee_buffer_clean (&conn->request_original); 
     286                                cherokee_buffer_add_buffer (&conn->request_original, &conn->request); 
     287 
    285288                                cherokee_buffer_clean (&conn->request); 
    286289                                cherokee_buffer_add (&conn->request, index, index_len);                          
     
    288291                                TRACE (ENTRIES, "top level index matched %s\n", index); 
    289292 
     293                                BIT_SET (conn->options, conn_op_root_index); 
    290294                                return ret_eagain; 
    291295                        } 
    292296 
    293                         /* Stat() the possible new path 
     297                        /* stat() the possible new path 
    294298                         */ 
    295299                        cherokee_buffer_add (&conn->local_directory, index, index_len); 
  • cherokee/trunk/cherokee/handler_file.c

    r597 r639  
    672672                 * off again the TCP_CORK flag 
    673673                 */ 
    674                 if (conn->tcp_cork) { 
    675                         cherokee_connection_set_cork (conn, 0); 
     674                if (conn->options & conn_op_tcp_cork) { 
     675                        cherokee_connection_set_cork (conn, false); 
    676676                } 
    677677 
  • cherokee/trunk/cherokee/macros.h

    r638 r639  
    235235#define INT_TO_POINTER(integer) ((void*)((long)(integer))) 
    236236 
     237/* Bit masks 
     238 */ 
     239#define BIT_SET(var,bit)    var |= bit 
     240#define BIT_UNSET(var,bit)  var &= (~bit) 
    237241 
    238242/* Format string for off_t and size_t 
  • cherokee/trunk/cherokee/thread.c

    r637 r639  
    500500        /* TCP cork 
    501501         */ 
    502         if (conn->tcp_cork) { 
    503                 cherokee_connection_set_cork (conn, 0); 
     502        if (conn->options & conn_op_tcp_cork) { 
     503                cherokee_connection_set_cork (conn, false); 
    504504        } 
    505505 
  • cherokee/trunk/qa/run-tests.py

    r610 r639  
    200200    pid = os.fork() 
    201201    if pid == 0: 
    202         if valgrind
     202        if valgrind != None
    203203            if valgrind[:3] == 'hel': 
    204204                os.execl (VALGRIND_PATH, "valgrind", "--tool=helgrind", server, "-C", cfg_file)