diff --git a/configure.ac b/configure.ac index 50e653b5fc2..9c1911a3aed 100644 --- a/configure.ac +++ b/configure.ac @@ -1928,19 +1928,6 @@ AM_CONDITIONAL([BUILD_HTTP_LOAD], [test x"$ac_cv_func_epoll_ctl" = x"yes"]) # We should only build traffic_top if we have curses AM_CONDITIONAL([BUILD_TRAFFIC_TOP], [test "x$ax_cv_curses" = "xyes"]) -AC_CHECK_HEADERS([kclangc.h], [ - AC_CHECK_LIB([kyotocabinet], [kcdbopen], [ - AC_SUBST([LIB_KYOTOCABINET], ["-lkyotocabinet"]) - has_kyotocabinet=1 - ], [ - has_kyotocabinet=0 - ]) -], -[has_kyotocabinet=0] -) -AC_SUBST(has_kyotocabinet) -AM_CONDITIONAL([HAS_KYOTOCABINET], [ test "x${has_kyotocabinet}" = "x1" ]) - # ----------------------------------------------------------------------------- # 5. CHECK FOR HEADER FILES diff --git a/plugins/Makefile.am b/plugins/Makefile.am index a2f4e89ae36..e31a77d6b17 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -119,10 +119,6 @@ if BUILD_STEK_SHARE_PLUGIN include experimental/stek_share/Makefile.inc endif -if HAS_KYOTOCABINET -include experimental/cache_key_genid/Makefile.inc -endif - if BUILD_IMAGE_MAGICK_PLUGINS include experimental/magick/Makefile.inc endif diff --git a/plugins/experimental/cache_key_genid/Makefile.inc b/plugins/experimental/cache_key_genid/Makefile.inc deleted file mode 100644 index 442cfae98f6..00000000000 --- a/plugins/experimental/cache_key_genid/Makefile.inc +++ /dev/null @@ -1,23 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -pkglib_LTLIBRARIES += experimental/cache_key_genid/cache_key_genid.la - -experimental_cache_key_genid_cache_key_genid_la_SOURCES = \ - experimental/cache_key_genid/cache_key_genid.cc - -experimental_cache_key_genid_cache_key_genid_la_LDFLAGS = \ - $(AM_LDFLAGS) $(LIB_KYOTOCABINET) diff --git a/plugins/experimental/cache_key_genid/cache_key_genid.cc b/plugins/experimental/cache_key_genid/cache_key_genid.cc deleted file mode 100644 index e4083190bca..00000000000 --- a/plugins/experimental/cache_key_genid/cache_key_genid.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* cache-key-genid.c - Plugin to modify the URL used as a cache key for - * requests, without modifying the URL used for actually fetching data from - * the origin server. - */ - -#include -#include -#include -#include - -#define PLUGIN_NAME "cache-key-genid" - -static char genid_kyoto_db[PATH_MAX + 1]; - -// Find the host in url and set host to it -static void -get_genid_host(char **host, char *url) -{ - char *pt1; - char *pt2; - size_t host_len; - unsigned num = 1; - - pt1 = strstr(url, "//"); - - if (pt1) { - pt1 = pt1 + 2; - pt2 = strstr(pt1, "/"); - } - - if (pt1 && pt2 && pt2 > pt1) { - host_len = pt2 - pt1; - *host = calloc(num, host_len + 1); - strncpy(*host, pt1, host_len); - } -} - -/* get_genid - * Looks up the host's genid in the host->genid database - */ -static int -get_genid(char *host) -{ - KCDB *db; - char *vbuf; - size_t vsiz; - int answer = 0; - int host_size; - - /* create the database object */ - db = kcdbnew(); - - /* open the database */ - if (!kcdbopen(db, genid_kyoto_db, KCOREADER | KCONOLOCK)) { - Dbg(dbg_ctl, "could not open the genid database %s", genid_kyoto_db); - TSError("[%s] could not open the genid database %s: %s", PLUGIN_NAME, genid_kyoto_db, strerror(errno)); - return 0; - } - - vbuf = kcdbget(db, host, strlen(host), &vsiz); - - if (vbuf) { - Dbg(dbg_ctl, "kcdbget(%s) = %s", host, vbuf); - answer = (int)strtol(vbuf, nullptr, 10); - kcfree(vbuf); - } else { - host_size = strlen(host); - Dbg(dbg_ctl, "kcdbget(%s) - no record found, len(%d)", host, host_size); - answer = 0; - } - - kcdbclose(db); - return answer; -} - -/* handle_hook - * Fires on TS_EVENT_HTTP_READ_REQUEST_HDR events, gets the effectiveUrl - * finds the host, gets the generation ID, gen_id, for the host - * and runs TSCacheUrlSet to change the cache key for the read - */ -static int -handle_hook(TSCont *contp, TSEvent event, void *edata) -{ - TSHttpTxn txnp = static_cast(edata); - char *url = nullptr, *host = nullptr; - int url_length; - int gen_id; - int ok = 1; - - switch (event) { - case TS_EVENT_HTTP_READ_REQUEST_HDR: - Dbg(dbg_ctl, "handling TS_EVENT_HTTP_READ_REQUEST_HDR"); - - if (ok) { - url = TSHttpTxnEffectiveUrlStringGet(txnp, &url_length); - if (!url) { - TSError("[%s] could not retrieve request url", PLUGIN_NAME); - ok = 0; - } - } - - if (ok) { - get_genid_host(&host, url); - if (!host) { - TSError("[%s] could not retrieve request host", PLUGIN_NAME); - ok = 0; - } - } - - if (ok) { - Dbg(dbg_ctl, "From url (%s) discovered host (%s)", url, host); - if ((gen_id = get_genid(host)) != 0) { - if (TSHttpTxnConfigIntSet(txnp, TS_CONFIG_HTTP_CACHE_GENERATION, gen_id) != TS_SUCCESS) { - Dbg(dbg_ctl, "Error, unable to modify cache url"); - TSError("[%s] Unable to set cache generation for %s to %d", PLUGIN_NAME, url, gen_id); - ok = 0; - } - } - } - - /* Clean up */ - if (url) { - TSfree(url); - } - if (host) { - TSfree(host); - } - TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); - break; - - default: - TSAssert(!"Unexpected event"); - ok = 0; - break; - } - - return ok; -} - -void -TSPluginInit(int argc, const char *argv[]) -{ - TSPluginRegistrationInfo info; - - info.plugin_name = (char *)PLUGIN_NAME; - info.vendor_name = (char *)"Apache Software Foundation"; - info.support_email = (char *)"dev@trafficserver.apache.org"; - - if (argc > 1) { - TSstrlcpy(genid_kyoto_db, argv[1], sizeof(genid_kyoto_db)); - } else { - TSError("[%s] plugin registration failed. check argv[1] for db path", PLUGIN_NAME); - return; - } - - if (TSPluginRegister(&info) != TS_SUCCESS) { - TSError("[%s] plugin registration failed, check version", PLUGIN_NAME); - return; - } - - TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, TSContCreate(reinterpret_cast(handle_hook), nullptr)); -}