Stress more with MockedHelloWorld

This commit is contained in:
Alex Hultman
2020-01-12 18:52:46 +01:00
parent 42977d3570
commit 2de34fa3f6
2 changed files with 29 additions and 0 deletions
+21
View File
@@ -22,13 +22,34 @@ extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
}
}).post("/*", [](auto *res, auto *req) {
res->onAborted([]() {
/* We might as well use this opportunity to stress the loop a bit */
uWS::Loop::get()->defer([]() {
});
});
res->onData([res](std::string_view chunk, bool isEnd) {
if (isEnd) {
res->end(chunk);
}
});
}).any("/:candy/*", [](auto *res, auto *req) {
if (req->getParameter(0).length() == 0) {
free((void *) -1);
}
/* Some invalid queries */
req->getParameter(30000);
req->getParameter(-34234);
req->getHeader("yhello");
req->getQuery();
/*req->onAborted([]() {
});*/
/* As of now, this will be called immediately, but changes could make it properly deferred */
uWS::Loop::get()->defer([res]() {
res->end("Deferred answer here");
});
}).listen(9001, [](us_listen_socket_t *listenSocket) {
if (listenSocket) {
std::cout << "Listening on port " << 9001 << std::endl;
+8
View File
@@ -17,6 +17,8 @@ struct us_loop_t {
/* Post and pre callbacks */
void (*pre_cb)(struct us_loop_t *loop);
void (*post_cb)(struct us_loop_t *loop);
void (*wakeup_cb)(struct us_loop_t *loop);
};
struct us_loop_t *us_create_loop(void *hint, void (*wakeup_cb)(struct us_loop_t *loop), void (*pre_cb)(struct us_loop_t *loop), void (*post_cb)(struct us_loop_t *loop), unsigned int ext_size) {
@@ -27,10 +29,16 @@ struct us_loop_t *us_create_loop(void *hint, void (*wakeup_cb)(struct us_loop_t
loop->pre_cb = pre_cb;
loop->post_cb = post_cb;
loop->wakeup_cb = wakeup_cb;
return loop;
}
void us_wakeup_loop(struct us_loop_t *loop) {
/* We do this immediately as of now, could be delayed to next iteration */
loop->wakeup_cb(loop);
}
void us_loop_free(struct us_loop_t *loop) {
free(loop);
}