Changeset 1515

Show
Ignore:
Timestamp:
01/14/2007 08:21:26 AM (21 months ago)
Author:
jakabosky
Message:

fixed a few bugs with the connection pool and backlog.
Added proxy-core.max-keep-alive-requests option.

Location:
trunk/src
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/mod_proxy_core.c

    r1512 r1515  
    2525#define CONFIG_PROXY_CORE_PROTOCOL "proxy-core.protocol" 
    2626#define CONFIG_PROXY_CORE_DEBUG "proxy-core.debug" 
     27#define CONFIG_PROXY_CORE_MAX_KEEP_ALIVE "proxy-core.max-keep-alive-requests" 
    2728#define CONFIG_PROXY_CORE_BACKENDS "proxy-core.backends" 
    2829#define CONFIG_PROXY_CORE_REWRITE_REQUEST "proxy-core.rewrite-request" 
     
    229230                { CONFIG_PROXY_CORE_MAX_POOL_SIZE, NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 8 */ 
    230231                { CONFIG_PROXY_CORE_CHECK_LOCAL, NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },        /* 9 */ 
     232                { CONFIG_PROXY_CORE_MAX_KEEP_ALIVE, NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },       /* 10 */ 
    231233                { NULL,                        NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET } 
    232234        }; 
     
    252254                s->request_rewrites   = proxy_rewrites_init(); 
    253255                s->check_local = 0; 
     256                s->max_keep_alive_requests = 0; 
    254257 
    255258                cv[0].destination = p->backends_arr; 
     
    261264                cv[8].destination = &(s->max_pool_size); 
    262265                cv[9].destination = &(s->check_local); 
     266                cv[10].destination = &(s->max_keep_alive_requests); 
    263267 
    264268                buffer_reset(p->balance_buf); 
     
    908912                switch (sess->proxy_con->state) { 
    909913                case PROXY_CONNECTION_STATE_CONNECTED: 
     914                        sess->proxy_con->request_count++; 
     915                        if (p->conf.debug) TRACE("request_count=%d", sess->proxy_con->request_count); 
     916                        if (sess->proxy_con->request_count >= p->conf.max_keep_alive_requests) { 
     917                                sess->is_closing = 1; 
     918                        } 
    910919                        /* 
    911920                         * Set the connection to idling if: 
     
    932941                case PROXY_CONNECTION_STATE_CLOSED: 
    933942                        proxy_remove_backend_connection(srv, sess); 
    934                         /* return so we don't wakeup a backlog connection. */ 
    935                         return HANDLER_GO_ON; 
    936943                case PROXY_CONNECTION_STATE_IDLE: 
    937944                default: 
     
    945952                connection *next_con = req->con; 
    946953 
     954                if (p->conf.debug) TRACE("wakeup a connection from backlog: con=%d", next_con->sock->fd); 
    947955                joblist_append(srv, next_con); 
    948956 
     
    15341542        PATCH_OPTION(max_pool_size); 
    15351543        PATCH_OPTION(check_local); 
     1544        PATCH_OPTION(max_keep_alive_requests); 
    15361545 
    15371546        /* skip the first, the global context */ 
     
    15681577                        } else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_PROXY_CORE_CHECK_LOCAL))) { 
    15691578                                PATCH_OPTION(check_local); 
     1579                        } else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_PROXY_CORE_MAX_KEEP_ALIVE))) { 
     1580                                PATCH_OPTION(max_keep_alive_requests); 
    15701581                        } 
    15711582                } 
     
    16581669        proxy_session *sess = con->plugin_ctx[p->id]; 
    16591670 
     1671        if (p->conf.debug) TRACE("proxy_connection_reset (%d)", con->sock->fd); 
    16601672        if (!sess) return HANDLER_GO_ON; 
    16611673 
     
    17941806                                req->con = con; 
    17951807 
    1796 #if 0 
    1797                                 TRACE("backlog: the con-pool is full, putting %s (%d) into the backlog", BUF_STR(con->uri.path), con->sock->fd); 
    1798 #endif 
     1808                                if (p->conf.debug)TRACE("backlog: the con-pool is full, putting %s (%d) into the backlog", BUF_STR(con->uri.path), con->sock->fd); 
    17991809                                proxy_backlog_push(p->conf.backlog, req); 
    18001810 
     
    18751885        UNUSED(srv); 
    18761886 
     1887        if (p->conf.debug) TRACE("proxy_connection_close (%d)", con->sock->fd); 
    18771888        if (con->mode != p->id) return HANDLER_GO_ON; 
    18781889 
     
    19381949                connection *con = req->con; 
    19391950 
     1951                if (p->debug) TRACE("wakeup a connection from backlog: con=%d", con->sock->fd); 
    19401952                joblist_append(srv, con); 
    19411953 
  • trunk/src/mod_proxy_core.h

    r1512 r1515  
    2929        unsigned short max_pool_size; 
    3030        unsigned short check_local; 
     31        unsigned short max_keep_alive_requests; 
    3132 
    3233        proxy_balance_t balancer; 
  • trunk/src/mod_proxy_core_backlog.c

    r1496 r1515  
    8787                cur->next = NULL; 
    8888 
    89                 proxy_request_free(req); 
     89                proxy_request_free(cur); 
    9090 
    9191                return 0; 
  • trunk/src/mod_proxy_core_pool.c

    r1496 r1515  
    113113                 */ 
    114114 
    115                 if (address->used == pool->max_size) return PROXY_CONNECTIONPOOL_FULL; 
     115                if (pool->used == pool->max_size) return PROXY_CONNECTIONPOOL_FULL; 
    116116 
    117117                proxy_con = proxy_connection_init(); 
  • trunk/src/mod_proxy_core_pool.h

    r1496 r1515  
    2424        iosocket *sock; 
    2525 
     26        unsigned short request_count; /* used for max-keep-alive-requests */ 
    2627        time_t last_read; /* timeout handling for keep-alive connections */ 
    2728        time_t last_write;