From d8cf40597a4270d9d0ed904709ce78d0bc67f8a6 Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Tue, 12 Jul 2005 18:25:18 +0000 Subject: [PATCH] replace spaces by _ for memcache git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.3.x@443 152afb58-edef-0310-8abb-c4023f1b3aa9 --- src/mod_trigger_b4_dl.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mod_trigger_b4_dl.c b/src/mod_trigger_b4_dl.c index ff66341b..35a8435a 100644 --- a/src/mod_trigger_b4_dl.c +++ b/src/mod_trigger_b4_dl.c @@ -350,6 +350,8 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) { /* X-Forwarded-For contains the ip behind the proxy */ remote_ip = ds->value->ptr; + + /* memcache can't handle spaces */ } else { remote_ip = inet_ntop_cache_get_ip(srv, &(con->dst_addr)); } @@ -385,6 +387,10 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) { buffer_copy_string_buffer(p->tmp_buf, p->conf.mc_namespace); buffer_append_string(p->tmp_buf, remote_ip); + for (i = 0; i < p->tmp_buf->used - 1; i++) { + if (p->tmp_buf->ptr[i] == ' ') p->tmp_buf->ptr[i] = '-'; + } + if (0 != mc_set(p->conf.mc, CONST_BUF_LEN(p->tmp_buf), (char *)&(srv->cur_ts), sizeof(srv->cur_ts), @@ -440,13 +446,6 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) { log_error_write(srv, __FILE__, __LINE__, "s", "delete failed"); } - } else if (p->conf.mc) { - if (0 != mc_delete(p->conf.mc, - (char *)remote_ip, strlen(remote_ip), - 0)) { - log_error_write(srv, __FILE__, __LINE__, "s", - "insert failed"); - } } return HANDLER_FINISHED; @@ -469,6 +468,10 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) { buffer_copy_string_buffer(p->tmp_buf, p->conf.mc_namespace); buffer_append_string(p->tmp_buf, remote_ip); + for (i = 0; i < p->tmp_buf->used - 1; i++) { + if (p->tmp_buf->ptr[i] == ' ') p->tmp_buf->ptr[i] = '-'; + } + /** * * memcached is do expiration for us, as long as we can fetch it every thing is ok