Changeset 893

Show
Ignore:
Timestamp:
08/13/07 11:27:14 (1 year ago)
Author:
adefacc
Message:

win32 optimization + micro cleanups

Files:

Legend:

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

    r892 r893  
     12007-08-13  A.D.F  <adefacc@tin.it> 
     2 
     3        * cherokee/server.c 
     4          - added srv->bogo_now to cherokee_win32_shutdown_signalled() 
     5            call; 
     6 
     7        * cherokee/win32_misc.h, 
     8          cherokee/win32_misc.c 
     9          - added a formal parameter (time) to 
     10            cherokee_win32_shutdown_signalled(), in order to execute 
     11            shutdown test only once a second; 
     12 
     13        * cherokee/connection.c 
     14          - build_response_header(), don't add headers with this version; 
     15          - moved a cherokee_buffer_ensure_size(header_buffer) 
     16            near to the other call to cherokee_buffer_ensure_size(buffer); 
     17          - build_response_header__authenticate(), removed a couple 
     18            of calls to cherokee_buffer_ensure_addlen() because 
     19            they are no more needed in that place (buffer is large enough 
     20            and buffer reallocation already take care to use increments 
     21            with predefined chunk size). 
     22 
    1232007-08-10  A.D.F  <adefacc@tin.it> 
    224 
  • cherokee/trunk/cherokee/connection.c

    r891 r893  
    402402         */ 
    403403        if (conn->auth_type & http_auth_basic) { 
    404                 cherokee_buffer_ensure_addlen (buffer, 31 + conn->realm_ref->len + 4); 
    405404                cherokee_buffer_add_str (buffer, "WWW-Authenticate: Basic realm=\""); 
    406405                cherokee_buffer_add_buffer (buffer, conn->realm_ref); 
     
    415414                cherokee_thread_t *thread = CONN_THREAD(conn); 
    416415                cherokee_buffer_t *new_nonce = THREAD_TMP_BUF1(thread); 
    417  
    418                 cherokee_buffer_ensure_addlen (buffer, 
    419                                                 32 + conn->realm_ref->len + 4 + 32 + 32); 
    420416 
    421417                /* Realm 
     
    453449        switch (conn->header.version) { 
    454450        case http_version_09: 
    455                 /* TODO: remove HTTP headers in this version */ 
    456                 cherokee_buffer_add_str (buffer, "HTTP/0.9 ");  
    457                 break
     451                /* There are no HTTP headers in this version. 
     452                */ 
     453                return
    458454        case http_version_10: 
    459455                cherokee_buffer_add_str (buffer, "HTTP/1.0 ");  
     
    535531        /* Try to get the headers from the handler 
    536532         */ 
    537         cherokee_buffer_ensure_size (&(conn->header_buffer), 384); 
    538533        ret = cherokee_handler_add_headers (conn->handler, &conn->header_buffer); 
    539534        if (unlikely (ret != ret_ok)) { 
     
    18691864         */ 
    18701865        if ((HANDLER_SUPPORT_LENGTH(conn->handler) == 0) &&  
    1871             (HANDLER_SUPPORT_MAYBE_LENGTH(conn->handler) == 0)) { 
     1866            (HANDLER_SUPPORT_MAYBE_LENGTH(conn->handler) == 0) && 
     1867                conn->keepalive != 0) { 
    18721868                conn->keepalive = 0; 
    18731869        } 
    18741870 
    1875         /* Ensure the space for writing 
    1876          */ 
     1871        /* Ensure the space for headers and I/O buffer 
     1872         */ 
     1873        cherokee_buffer_ensure_size (&conn->header_buffer, 384); 
    18771874        cherokee_buffer_ensure_size (&conn->buffer, DEFAULT_READ_SIZE+1); 
    18781875 
     
    18811878 
    18821879 
    1883 ret_t  
     1880ret_t 
    18841881cherokee_connection_log_or_delay (cherokee_connection_t *conn) 
    18851882{ 
  • cherokee/trunk/cherokee/server.c

    r886 r893  
    13341334 
    13351335#ifdef _WIN32 
    1336         if (cherokee_win32_shutdown_signaled()) 
     1336        if (cherokee_win32_shutdown_signaled(srv->bogo_now)) 
    13371337                srv->wanna_exit = true; 
    13381338#endif 
    13391339 
    1340         /* Wanna exit
     1340        /* Wanna reinit
    13411341         */ 
    13421342        if (unlikely (srv->wanna_reinit)) { 
     
    13461346        } 
    13471347         
     1348        /* Wanna exit ? 
     1349         */ 
    13481350        if (unlikely (srv->wanna_exit))  
    13491351                return ret_ok; 
  • cherokee/trunk/cherokee/win32_misc.c

    r862 r893  
    10231023} 
    10241024 
     1025 
    10251026static bool 
    10261027init_security_attributes_allow_all (struct security_attributes *obj) 
     
    10521053} 
    10531054 
    1054 int 
    1055 cherokee_win32_shutdown_signaled() 
     1055 
     1056/* This function is called by only one task 
     1057 * and it returns true if the process has to stop / exit. 
     1058 */ 
     1059bool 
     1060cherokee_win32_shutdown_signaled(time_t bogo_now) 
    10561061{ 
    10571062        static HANDLE exit_event = NULL; 
     1063        static time_t bogo_prev = 0; 
    10581064 
    10591065        if (!exit_event) { 
    10601066                exit_event = create_event (EXIT_EVENT_NAME, TRUE, FALSE, FALSE); 
    10611067                if (!exit_event) 
    1062                   return 1; 
    1063         } 
    1064  
     1068                        return true; 
     1069        } 
     1070 
     1071        /* If at least one second has not elapsed since last test, 
     1072         * then return now. 
     1073         */ 
     1074        if (bogo_prev == bogo_now) 
     1075                return false; 
     1076 
     1077        bogo_prev = bogo_now; 
     1078 
     1079        /* OK, test and return result. 
     1080         */ 
    10651081        return WaitForSingleObject (exit_event, (DWORD) 0) == WAIT_OBJECT_0; 
    10661082} 
     1083 
    10671084 
    10681085int 
  • cherokee/trunk/cherokee/win32_misc.h

    r862 r893  
    3131#include <fcntl.h> 
    3232#include <winsock2.h> 
     33#include <time.h> 
    3334 
    3435#include "buffer.h" 
     
    4546 
    4647int           cherokee_win32_stat (const char *path, struct stat *buf); 
    47 int           cherokee_win32_shutdown_signaled(); 
     48bool          cherokee_win32_shutdown_signaled(time_t bogo_now); 
    4849int           cherokee_win32_mkstemp (cherokee_buffer_t *buffer); 
    4950