diff --git a/Makefile b/Makefile index 37817c2..50b95b1 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ .PHONY: test test_e2e test: - docker-compose build test && docker-compose run --rm test - docker-compose down -t 0 + docker compose build test && docker compose run --rm test + docker compose down -t 0 test_e2e: - docker-compose build test_e2e && docker-compose run --rm test_e2e - docker-compose down -t 0 + docker compose build test_e2e && docker compose run --rm test_e2e + docker compose down -t 0 diff --git a/docker/Dockerfile.e2e b/docker/Dockerfile.e2e index d64f9e1..213513a 100644 --- a/docker/Dockerfile.e2e +++ b/docker/Dockerfile.e2e @@ -2,7 +2,7 @@ FROM rust:1.63.0-alpine3.16 USER root -RUN apk add --no-cache musl-dev openssl-dev pkgconfig && cargo install websocat +RUN apk add --no-cache musl-dev openssl-dev pkgconfig && cargo install websocat@1.10.0 COPY ./docker/test_e2e.sh /usr/local/bin/test_e2e RUN chmod +x /usr/local/bin/test_e2e diff --git a/docker/Dockerfile.nginx b/docker/Dockerfile.nginx index 00b50cf..66c3caf 100644 --- a/docker/Dockerfile.nginx +++ b/docker/Dockerfile.nginx @@ -1,4 +1,4 @@ -FROM k8s.gcr.io/ingress-nginx/controller:v0.44.0 as builder +FROM k8s.gcr.io/ingress-nginx/controller:v1.1.1 as builder USER root @@ -14,5 +14,5 @@ RUN cd ./nginx && \ --add-dynamic-module=../ngx_http_websocket_stat_module && \ make modules -FROM k8s.gcr.io/ingress-nginx/controller:v0.44.0 +FROM k8s.gcr.io/ingress-nginx/controller:v1.1.1 COPY --from=builder /tmp/nginx/objs/ngx_http_websocket_stat_module.so /etc/nginx/modules/ diff --git a/src/ngx_http_websocket_stat_format.c b/src/ngx_http_websocket_stat_format.c index 3086a83..7009f44 100644 --- a/src/ngx_http_websocket_stat_format.c +++ b/src/ngx_http_websocket_stat_format.c @@ -40,9 +40,9 @@ compare_occurance(const void *_first, const void *_second) ngx_array_t * ngx_array_create(void *pool, size_t size, size_t el_size) { - ngx_array_t *res = malloc(sizeof(ngx_array_t)); + ngx_array_t *res = ngx_palloc(pool, sizeof(ngx_array_t)); res->nelts = 0; - res->elts = malloc(100 * el_size); + res->elts = ngx_palloc(pool, 100 * el_size); res->el_size = el_size; return res; } @@ -191,7 +191,7 @@ char * apply_template(compiled_template *template_cmpl, ngx_http_request_t *r, void *data) { - char *result = malloc(strlen(template_cmpl->compiled_template_str) + 1); + char *result = ngx_palloc(template_cmpl->pool, strlen(template_cmpl->compiled_template_str) + 1); strcpy(result, template_cmpl->compiled_template_str); unsigned int i; char buff[256]; diff --git a/src/ngx_http_websocket_stat_module.c b/src/ngx_http_websocket_stat_module.c index 17ac7b4..769ef02 100644 --- a/src/ngx_http_websocket_stat_module.c +++ b/src/ngx_http_websocket_stat_module.c @@ -117,7 +117,7 @@ ws_do_log(compiled_template *template, ngx_http_request_t *r, void *ctx) if (!log_line) return; ngx_write_fd(srvcf->ws_log->file->fd, log_line, strlen(log_line)); ngx_write_fd(srvcf->ws_log->file->fd, &CARET_RETURN, sizeof(char)); - free(log_line); + ngx_pfree(template->pool, log_line); } static int