Changeset 430

Show
Ignore:
Timestamp:
07/08/2005 10:28:46 PM (3 years ago)
Author:
jan
Message:

added namespace support for memcached

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/lighttpd-1.3.x/src/mod_trigger_b4_dl.c

    r429 r430  
    4242         
    4343        array  *mc_hosts; 
     44        buffer *mc_namespace; 
    4445#if defined(HAVE_PCRE_H) 
    4546        pcre *trigger_regex; 
     
    5960typedef struct { 
    6061        PLUGIN_DATA; 
     62         
     63        buffer *tmp_buf; 
    6164         
    6265        plugin_config **config_storage; 
     
    7073         
    7174        p = calloc(1, sizeof(*p)); 
     75         
     76        p->tmp_buf = buffer_init(); 
    7277         
    7378        return p; 
     
    9297                        buffer_free(s->deny_url); 
    9398                         
     99                        buffer_free(s->mc_namespace); 
     100                        array_free(s->mc_hosts); 
     101                         
    94102#if defined(HAVE_PCRE_H) 
    95103                        if (s->trigger_regex) pcre_free(s->trigger_regex); 
     
    111119                free(p->config_storage); 
    112120        } 
     121         
     122        buffer_free(p->tmp_buf); 
    113123         
    114124        free(p); 
     
    131141                { "trigger-before-download.trigger-timeout", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 4 */ 
    132142                { "trigger-before-download.memcache-hosts",  NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },        /* 5 */ 
     143                { "trigger-before-download.memcache-namespace", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },    /* 6 */ 
    133144                { NULL,                        NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET } 
    134145        }; 
     
    159170                cv[4].destination = &(s->trigger_timeout); 
    160171                cv[5].destination = s->mc_hosts; 
     172                cv[6].destination = s->mc_namespace; 
    161173                 
    162174                p->config_storage[i] = s; 
     
    268280                        } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("trigger-before-download.deny-url"))) { 
    269281                                PATCH(deny_url); 
     282                        } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("trigger-before-download.memcache-namespace"))) { 
     283                                PATCH(mc_namespace); 
    270284                        } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("trigger-before-download.memcache-hosts"))) { 
    271285#if defined(HAVE_MEMCACHE_H) 
     
    356370                } else if (p->conf.mc) { 
    357371# if defined(HAVE_MEMCACHE_H) 
     372                        buffer_copy_string_buffer(p->tmp_buf, p->conf.mc_namespace); 
     373                        buffer_append_string(p->tmp_buf, remote_ip); 
     374                         
    358375                        if (0 != mc_set(p->conf.mc,  
    359                                         (char *)remote_ip, strlen(remote_ip), 
     376                                        CONST_BUF_LEN(p->tmp_buf), 
    360377                                        (char *)&(srv->cur_ts), sizeof(srv->cur_ts), 
    361378                                        p->conf.trigger_timeout, 0)) { 
     
    436453                        void *r; 
    437454                         
     455                        buffer_copy_string_buffer(p->tmp_buf, p->conf.mc_namespace); 
     456                        buffer_append_string(p->tmp_buf, remote_ip); 
     457                         
    438458                        /** 
    439459                         *  
     
    443463                         */ 
    444464                        if (NULL == (r = mc_aget(p->conf.mc,  
    445                                                  (char *)remote_ip, strlen(remote_ip)))) { 
     465                                                 CONST_BUF_LEN(p->tmp_buf) 
     466                                                 ))) { 
    446467                                 
    447468                                response_header_insert(srv, con, CONST_STR_LEN("Location"), CONST_BUF_LEN(p->conf.deny_url)); 
     
    456477                        /* set a new timeout */ 
    457478                        if (0 != mc_set(p->conf.mc,  
    458                                         (char *)remote_ip, strlen(remote_ip), 
     479                                        CONST_BUF_LEN(p->tmp_buf), 
    459480                                        (char *)&(srv->cur_ts), sizeof(srv->cur_ts), 
    460481                                        p->conf.trigger_timeout, 0)) {