Skip to content

Commit

Permalink
proxy: embed routelib
Browse files Browse the repository at this point in the history
`-o proxy_config=routelib` will use the binary-distributed routelib
library
  • Loading branch information
dormando committed Oct 23, 2024
1 parent 8203c93 commit 2b4ab93
Show file tree
Hide file tree
Showing 4 changed files with 3,031 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ memcached_SOURCES += proto_proxy.c proto_proxy.h vendor/mcmc/mcmc.h \
proxy_config.c proxy_ring_hash.c \
proxy_internal.c \
proxy_tls.c proxy_tls.h \
md5.c md5.h
md5.c md5.h \
vendor/routelib/routelib.h
endif

if ENABLE_EXTSTORE
Expand Down Expand Up @@ -151,6 +152,7 @@ EXTRA_DIST = doc scripts t memcached.spec memcached_dtrace.d version.m4 README.m
EXTRA_DIST += vendor/Makefile vendor/lua/doc/* vendor/lua/Makefile vendor/lua/README
EXTRA_DIST += vendor/lua/src/*.c vendor/lua/src/*.h vendor/lua/src/Makefile
EXTRA_DIST += vendor/mcmc/LICENSE vendor/mcmc/Makefile vendor/mcmc/README.md vendor/mcmc/*.c vendor/mcmc/*.h
EXTRA_DIST += vendor/routelib/*.h

if ENABLE_PROXY
SUBDIRS += vendor
Expand Down
7 changes: 6 additions & 1 deletion proxy_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// TODO (v2): move worker thread related code back out of here.

#include "proxy.h"
#include "vendor/routelib/routelib.h"

// not using queue.h becuase those require specific storage for HEAD.
// it's not possible to have the HEAD simply be in the proxy context because
Expand Down Expand Up @@ -455,7 +456,11 @@ static int proxy_load_files(proxy_ctx_t *ctx) {
memset(db->buf, 0, db->size);
db->used = 0;

res = luaL_loadfile(L, db->fname);
if (strcmp(db->fname, "routelib") == 0) {
res = luaL_loadbuffer(L, routelib_lua, routelib_lua_len, "routelib");
} else {
res = luaL_loadfile(L, db->fname);
}
if (res != LUA_OK) {
fprintf(stderr, "ERROR: Failed to load proxy_startfile: %s\n", lua_tostring(L, -1));
return -1;
Expand Down
3 changes: 3 additions & 0 deletions vendor/routelib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
generated by:
xxd -i routelib.lua > routelib.h
then changing unsigned char to just char.
Loading

0 comments on commit 2b4ab93

Please sign in to comment.