Unbreak test

This commit is contained in:
cpq 2022-10-28 15:35:40 +01:00
parent 610e32714c
commit bbc0c0df94
8 changed files with 64 additions and 63 deletions

View File

@ -40,7 +40,6 @@ jobs:
env: env:
IPV6: 0 IPV6: 0
CC: ${{ matrix.targets.toolchain }}-gcc CC: ${{ matrix.targets.toolchain }}-gcc
SSL:
ASAN: ASAN:
ASAN_OPTIONS: ASAN_OPTIONS:
RUN: ${{ matrix.targets.qemu }} -L /usr/${{ matrix.targets.toolchain }} RUN: ${{ matrix.targets.qemu }} -L /usr/${{ matrix.targets.toolchain }}
@ -55,7 +54,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: sudo apt-get update ; sudo apt-get install libmbedtls-dev valgrind - run: sudo apt-get update ; sudo apt-get install libmbedtls-dev valgrind
- run: make unamalgamated SSL= - run: make unamalgamated
- run: make valgrind IPV6=0 - run: make valgrind IPV6=0
- run: make mg_prefix - run: make mg_prefix
examples: examples:

View File

@ -4,7 +4,7 @@ DEFS ?= -DMG_MAX_HTTP_HEADERS=7 -DMG_ENABLE_LINES -DMG_ENABLE_PACKED_FS=1 -DMG_E
WARN ?= -pedantic -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion -Wundef WARN ?= -pedantic -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion -Wundef
OPTS ?= -O3 -g3 OPTS ?= -O3 -g3
INCS ?= -Isrc -I. INCS ?= -Isrc -I.
SSL ?= MBEDTLS SSL ?=
CWD ?= $(realpath $(CURDIR)) CWD ?= $(realpath $(CURDIR))
ENV ?= -e Tmp=. -e WINEDEBUG=-all ENV ?= -e Tmp=. -e WINEDEBUG=-all
DOCKER ?= docker run --platform linux/amd64 --rm $(ENV) -v $(CWD):$(CWD) -w $(CWD) DOCKER ?= docker run --platform linux/amd64 --rm $(ENV) -v $(CWD):$(CWD) -w $(CWD)

View File

@ -1349,6 +1349,7 @@ struct mg_fs mg_fs_posix = {p_stat, p_list, p_open, p_close, p_read,
// Chunk deletion marker is the MSB in the "processed" counter // Chunk deletion marker is the MSB in the "processed" counter
#define MG_DMARK ((size_t) 1 << (sizeof(size_t) * 8 - 1)) #define MG_DMARK ((size_t) 1 << (sizeof(size_t) * 8 - 1))
@ -2310,6 +2311,34 @@ static void http_cb(struct mg_connection *c, int ev, void *evd, void *fnd) {
(void) evd, (void) fnd; (void) evd, (void) fnd;
} }
static void mg_hfn(struct mg_connection *c, int ev, void *ev_data, void *fnd) {
if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
if (mg_http_match_uri(hm, "/quit")) {
mg_http_reply(c, 200, "", "ok\n");
c->is_draining = 1;
c->label[0] = 'X';
} else if (mg_http_match_uri(hm, "/debug")) {
int level = (int) mg_json_get_long(hm->body, "$.level", MG_LL_DEBUG);
mg_log_set(level);
mg_http_reply(c, 200, "", "Debug level set to %d\n", level);
} else {
mg_http_reply(c, 200, "", "hi\n");
}
} else if (ev == MG_EV_CLOSE) {
if (c->label[0] == 'X') *(bool *) fnd = true;
}
}
void mg_hello(const char *url) {
struct mg_mgr mgr;
bool done = false;
mg_mgr_init(&mgr);
if (mg_http_listen(&mgr, url, mg_hfn, &done) == NULL) done = true;
while (done == false) mg_mgr_poll(&mgr, 100);
mg_mgr_free(&mgr);
}
struct mg_connection *mg_http_connect(struct mg_mgr *mgr, const char *url, struct mg_connection *mg_http_connect(struct mg_mgr *mgr, const char *url,
mg_event_handler_t fn, void *fn_data) { mg_event_handler_t fn, void *fn_data) {
struct mg_connection *c = mg_connect(mgr, url, fn, fn_data); struct mg_connection *c = mg_connect(mgr, url, fn, fn_data);
@ -3488,34 +3517,6 @@ struct mg_timer *mg_timer_add(struct mg_mgr *mgr, uint64_t milliseconds,
return t; return t;
} }
static void mg_hfn(struct mg_connection *c, int ev, void *ev_data, void *fnd) {
if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
if (mg_http_match_uri(hm, "/quit")) {
mg_http_reply(c, 200, "", "ok\n");
c->is_draining = 1;
c->label[0] = 'X';
} else if (mg_http_match_uri(hm, "/debug")) {
int level = (int) mg_json_get_long(hm->body, "$.level", MG_LL_DEBUG);
mg_log_set(level);
mg_http_reply(c, 200, "", "Debug level set to %d\n", level);
} else {
mg_http_reply(c, 200, "", "hi\n");
}
} else if (ev == MG_EV_CLOSE) {
if (c->label[0] == 'X') *(bool *) fnd = true;
}
}
void mg_hello(const char *url) {
struct mg_mgr mgr;
bool done = false;
mg_mgr_init(&mgr);
if (mg_http_listen(&mgr, url, mg_hfn, &done) == NULL) done = true;
while (done == false) mg_mgr_poll(&mgr, 100);
mg_mgr_free(&mgr);
}
void mg_mgr_free(struct mg_mgr *mgr) { void mg_mgr_free(struct mg_mgr *mgr) {
struct mg_connection *c; struct mg_connection *c;
struct mg_timer *tmp, *t = mgr->timers; struct mg_timer *tmp, *t = mgr->timers;

View File

@ -1103,7 +1103,6 @@ char *mg_straddr(struct mg_addr *, char *, size_t);
bool mg_aton(struct mg_str str, struct mg_addr *addr); bool mg_aton(struct mg_str str, struct mg_addr *addr);
char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len); char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len);
int mg_mkpipe(struct mg_mgr *, mg_event_handler_t, void *, bool udp); int mg_mkpipe(struct mg_mgr *, mg_event_handler_t, void *, bool udp);
void mg_hello(const char *url);
// These functions are used to integrate with custom network stacks // These functions are used to integrate with custom network stacks
struct mg_connection *mg_alloc_conn(struct mg_mgr *); struct mg_connection *mg_alloc_conn(struct mg_mgr *);
@ -1183,6 +1182,7 @@ void mg_http_bauth(struct mg_connection *, const char *user, const char *pass);
struct mg_str mg_http_get_header_var(struct mg_str s, struct mg_str v); struct mg_str mg_http_get_header_var(struct mg_str s, struct mg_str v);
size_t mg_http_next_multipart(struct mg_str, size_t, struct mg_http_part *); size_t mg_http_next_multipart(struct mg_str, size_t, struct mg_http_part *);
int mg_http_status(const struct mg_http_message *hm); int mg_http_status(const struct mg_http_message *hm);
void mg_hello(const char *url);
void mg_http_serve_ssi(struct mg_connection *c, const char *root, void mg_http_serve_ssi(struct mg_connection *c, const char *root,

View File

@ -2,6 +2,7 @@
#include "base64.h" #include "base64.h"
#include "fmt.h" #include "fmt.h"
#include "http.h" #include "http.h"
#include "json.h"
#include "log.h" #include "log.h"
#include "net.h" #include "net.h"
#include "ssi.h" #include "ssi.h"
@ -970,6 +971,34 @@ static void http_cb(struct mg_connection *c, int ev, void *evd, void *fnd) {
(void) evd, (void) fnd; (void) evd, (void) fnd;
} }
static void mg_hfn(struct mg_connection *c, int ev, void *ev_data, void *fnd) {
if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
if (mg_http_match_uri(hm, "/quit")) {
mg_http_reply(c, 200, "", "ok\n");
c->is_draining = 1;
c->label[0] = 'X';
} else if (mg_http_match_uri(hm, "/debug")) {
int level = (int) mg_json_get_long(hm->body, "$.level", MG_LL_DEBUG);
mg_log_set(level);
mg_http_reply(c, 200, "", "Debug level set to %d\n", level);
} else {
mg_http_reply(c, 200, "", "hi\n");
}
} else if (ev == MG_EV_CLOSE) {
if (c->label[0] == 'X') *(bool *) fnd = true;
}
}
void mg_hello(const char *url) {
struct mg_mgr mgr;
bool done = false;
mg_mgr_init(&mgr);
if (mg_http_listen(&mgr, url, mg_hfn, &done) == NULL) done = true;
while (done == false) mg_mgr_poll(&mgr, 100);
mg_mgr_free(&mgr);
}
struct mg_connection *mg_http_connect(struct mg_mgr *mgr, const char *url, struct mg_connection *mg_http_connect(struct mg_mgr *mgr, const char *url,
mg_event_handler_t fn, void *fn_data) { mg_event_handler_t fn, void *fn_data) {
struct mg_connection *c = mg_connect(mgr, url, fn, fn_data); struct mg_connection *c = mg_connect(mgr, url, fn, fn_data);

View File

@ -65,3 +65,4 @@ void mg_http_bauth(struct mg_connection *, const char *user, const char *pass);
struct mg_str mg_http_get_header_var(struct mg_str s, struct mg_str v); struct mg_str mg_http_get_header_var(struct mg_str s, struct mg_str v);
size_t mg_http_next_multipart(struct mg_str, size_t, struct mg_http_part *); size_t mg_http_next_multipart(struct mg_str, size_t, struct mg_http_part *);
int mg_http_status(const struct mg_http_message *hm); int mg_http_status(const struct mg_http_message *hm);
void mg_hello(const char *url);

View File

@ -230,34 +230,6 @@ struct mg_timer *mg_timer_add(struct mg_mgr *mgr, uint64_t milliseconds,
return t; return t;
} }
static void mg_hfn(struct mg_connection *c, int ev, void *ev_data, void *fnd) {
if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
if (mg_http_match_uri(hm, "/quit")) {
mg_http_reply(c, 200, "", "ok\n");
c->is_draining = 1;
c->label[0] = 'X';
} else if (mg_http_match_uri(hm, "/debug")) {
int level = (int) mg_json_get_long(hm->body, "$.level", MG_LL_DEBUG);
mg_log_set(level);
mg_http_reply(c, 200, "", "Debug level set to %d\n", level);
} else {
mg_http_reply(c, 200, "", "hi\n");
}
} else if (ev == MG_EV_CLOSE) {
if (c->label[0] == 'X') *(bool *) fnd = true;
}
}
void mg_hello(const char *url) {
struct mg_mgr mgr;
bool done = false;
mg_mgr_init(&mgr);
if (mg_http_listen(&mgr, url, mg_hfn, &done) == NULL) done = true;
while (done == false) mg_mgr_poll(&mgr, 100);
mg_mgr_free(&mgr);
}
void mg_mgr_free(struct mg_mgr *mgr) { void mg_mgr_free(struct mg_mgr *mgr) {
struct mg_connection *c; struct mg_connection *c;
struct mg_timer *tmp, *t = mgr->timers; struct mg_timer *tmp, *t = mgr->timers;

View File

@ -90,7 +90,6 @@ char *mg_straddr(struct mg_addr *, char *, size_t);
bool mg_aton(struct mg_str str, struct mg_addr *addr); bool mg_aton(struct mg_str str, struct mg_addr *addr);
char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len); char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len);
int mg_mkpipe(struct mg_mgr *, mg_event_handler_t, void *, bool udp); int mg_mkpipe(struct mg_mgr *, mg_event_handler_t, void *, bool udp);
void mg_hello(const char *url);
// These functions are used to integrate with custom network stacks // These functions are used to integrate with custom network stacks
struct mg_connection *mg_alloc_conn(struct mg_mgr *); struct mg_connection *mg_alloc_conn(struct mg_mgr *);