Compare commits
2 Commits
6af3e6ad6d
...
f97de2fe83
| Author | SHA1 | Date |
|---|---|---|
|
|
f97de2fe83 | |
|
|
29f4edc059 |
|
|
@ -1,4 +1,15 @@
|
|||
data/
|
||||
build/
|
||||
trie/build/
|
||||
.git/
|
||||
*
|
||||
|
||||
!src/
|
||||
!include/
|
||||
|
||||
!lsm/src/
|
||||
!lsm/include/
|
||||
!lsm/Makefile
|
||||
!lsm/config.mk
|
||||
|
||||
!thirdparty/include
|
||||
!thirdparty/src
|
||||
|
||||
!Makefile
|
||||
!config.mk
|
||||
|
|
|
|||
13
Dockerfile
13
Dockerfile
|
|
@ -1,11 +1,12 @@
|
|||
FROM alpine:3.18.0 AS builder
|
||||
FROM ubuntu:23.10 AS builder
|
||||
|
||||
ARG DI_VER=1.2.5
|
||||
|
||||
RUN apk add --update --no-cache \
|
||||
build-base \
|
||||
make \
|
||||
curl
|
||||
RUN apt update && \
|
||||
apt install -y --no-install-recommends \
|
||||
curl ca-certificates \
|
||||
build-essential \
|
||||
musl musl-dev musl-tools
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
|
@ -18,7 +19,7 @@ RUN curl -Lo - "https://github.com/Yelp/dumb-init/archive/refs/tags/v${DI_VER}.t
|
|||
|
||||
COPY . ./
|
||||
|
||||
RUN make CFLAGS='-O3' LDFLAGS='-static -flto' && \
|
||||
RUN make CFLAGS='-O3' LDFLAGS='-flto -static' && \
|
||||
strip build/lander && \
|
||||
readelf -d build/lander && \
|
||||
[ "$(readelf -d build/lander | grep NEEDED | wc -l)" = 0 ]
|
||||
|
|
|
|||
12
Makefile
12
Makefile
|
|
@ -35,15 +35,11 @@ all: $(BIN)
|
|||
.PHONY: objs
|
||||
objs: $(OBJS)
|
||||
|
||||
.PHONY: libtrie
|
||||
libtrie:
|
||||
$(MAKE) -C trie
|
||||
|
||||
.PHONY: liblsm
|
||||
liblsm:
|
||||
$(MAKE) -C lsm
|
||||
|
||||
$(BIN): libtrie liblsm $(OBJS)
|
||||
$(BIN): liblsm $(OBJS)
|
||||
$(CC) -o $@ $(OBJS) $(_LDFLAGS)
|
||||
|
||||
$(BUILD_DIR)/$(SRC_DIR)/%.c.o: $(SRC_DIR)/%.c
|
||||
|
|
@ -126,12 +122,14 @@ check:
|
|||
--enable=warning,style \
|
||||
-ithirdparty/* \
|
||||
-itrie/* \
|
||||
--quiet
|
||||
--inline-suppr \
|
||||
--check-level=exhaustive \
|
||||
--quiet \
|
||||
-j$(shell nproc)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)
|
||||
$(MAKE) -C trie clean
|
||||
$(MAKE) -C lsm clean
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ TEST_DIR = test
|
|||
THIRDPARTY_DIR = thirdparty
|
||||
|
||||
INC_DIRS = include $(THIRDPARTY_DIR)/include trie/include lsm/include
|
||||
LIBS = trie m lsm
|
||||
LIB_DIRS = ./trie/build ./lsm/build
|
||||
LIBS = m lsm
|
||||
LIB_DIRS = ./lsm/build
|
||||
|
||||
# -MMD: generate a .d file for every source file. This file can be imported by
|
||||
# make and makes make aware that a header file has been changed, ensuring an
|
||||
|
|
|
|||
13
landerctl
13
landerctl
|
|
@ -10,11 +10,11 @@ fi
|
|||
|
||||
|
||||
if [ "$1" = g ]; then
|
||||
curl -is "$URL/$2" |
|
||||
exec curl -is "$URL/$2" |
|
||||
sed -En 's/^[lL]ocation: (.*)/\1/p'
|
||||
|
||||
elif [ "$1" = s ] || [ "$1" = sl ]; then
|
||||
curl \
|
||||
exec curl \
|
||||
--fail \
|
||||
-w "${URL}%header{location}" \
|
||||
-XPOST \
|
||||
|
|
@ -23,7 +23,7 @@ elif [ "$1" = s ] || [ "$1" = sl ]; then
|
|||
"$URL/$1/$3"
|
||||
|
||||
elif [ "$1" = p ] || [ "$1" = pl ]; then
|
||||
curl \
|
||||
exec curl \
|
||||
--fail \
|
||||
-w "${URL}%header{location}" \
|
||||
-XPOST \
|
||||
|
|
@ -33,18 +33,19 @@ elif [ "$1" = p ] || [ "$1" = pl ]; then
|
|||
"$URL/$1/$3"
|
||||
|
||||
elif [ "$1" = f ] || [ "$1" = fl ]; then
|
||||
curl \
|
||||
exec curl \
|
||||
--fail \
|
||||
-v \
|
||||
-w "${URL}%header{location}" \
|
||||
-XPOST \
|
||||
-H "X-Api-Key: $API_KEY" \
|
||||
-H "X-Lander-Content-Type: ${content_type}" \
|
||||
-H "X-Lander-Filename: ${filename}" \
|
||||
--data-binary @"$2" \
|
||||
-T "$2" \
|
||||
"$URL/$1/$3"
|
||||
|
||||
elif [ "$1" = d ]; then
|
||||
curl \
|
||||
exec curl \
|
||||
--fail \
|
||||
-XDELETE \
|
||||
-H "X-Api-Key: $API_KEY" \
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ lsm_error lsm_store_init(lsm_store **ptr) {
|
|||
return lsm_error_ok;
|
||||
}
|
||||
|
||||
uint64_t lsm_store_size(const lsm_store *store) { return lsm_trie_size(store->trie); }
|
||||
uint64_t lsm_store_size(const lsm_store *store) {
|
||||
return lsm_trie_size(store->trie);
|
||||
}
|
||||
|
||||
lsm_error lsm_store_open_read(lsm_entry_handle **out, lsm_store *store,
|
||||
lsm_str *key) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ event_loop *event_loop_init() {
|
|||
event_loop *el = calloc(sizeof(event_loop), 1);
|
||||
|
||||
// No idea if this is a good starter value
|
||||
el->connections = calloc(sizeof(event_loop_conn), 16);
|
||||
el->connections = calloc(sizeof(event_loop_conn *), 16);
|
||||
el->connection_count = 16;
|
||||
|
||||
return el;
|
||||
|
|
@ -34,7 +34,7 @@ event_loop *event_loop_init() {
|
|||
int event_loop_put(event_loop *el, event_loop_conn *conn) {
|
||||
if ((size_t)conn->fd >= el->connection_count) {
|
||||
event_loop_conn **resized =
|
||||
realloc(el->connections, sizeof(event_loop_conn) * (conn->fd + 1));
|
||||
realloc(el->connections, sizeof(event_loop_conn *) * (conn->fd + 1));
|
||||
|
||||
if (resized == NULL) {
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "http_loop.h"
|
||||
#include "log.h"
|
||||
|
||||
// cppcheck-suppress syntaxError
|
||||
static const char *http_response_format = "HTTP/1.1 %i %s\n"
|
||||
"Server: lander/" LANDER_VERSION "\n"
|
||||
"Content-Length: %lu\n";
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ bool http_loop_step_body_to_buf(event_loop_conn *conn) {
|
|||
}
|
||||
|
||||
ctx->req.body.type = http_body_buf;
|
||||
ctx->req.body.buf = malloc(ctx->req.body.expected_len * sizeof(uint8_t));
|
||||
ctx->req.body.buf = malloc(ctx->req.body.expected_len * sizeof(char));
|
||||
ctx->req.body.len = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue