|
|
@ -93,14 +93,14 @@ module_free(struct module *module)
|
|
|
|
* @param argument_count
|
|
|
|
* @param argument_count
|
|
|
|
* @param stack_size
|
|
|
|
* @param stack_size
|
|
|
|
* @param max_memory
|
|
|
|
* @param max_memory
|
|
|
|
* @param timeout
|
|
|
|
* @param relative_deadline_us
|
|
|
|
* @param port
|
|
|
|
* @param port
|
|
|
|
* @param request_size
|
|
|
|
* @param request_size
|
|
|
|
* @returns A new module or NULL in case of failure
|
|
|
|
* @returns A new module or NULL in case of failure
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
struct module *
|
|
|
|
struct module *
|
|
|
|
module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_memory, u32 timeout, int port,
|
|
|
|
module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_memory, u32 relative_deadline_us,
|
|
|
|
int request_size, int response_size)
|
|
|
|
int port, int request_size, int response_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct module *module = (struct module *)malloc(sizeof(struct module));
|
|
|
|
struct module *module = (struct module *)malloc(sizeof(struct module));
|
|
|
|
if (!module) return NULL;
|
|
|
|
if (!module) return NULL;
|
|
|
@ -131,12 +131,12 @@ module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_m
|
|
|
|
strncpy(module->name, name, MODULE__MAX_NAME_LENGTH);
|
|
|
|
strncpy(module->name, name, MODULE__MAX_NAME_LENGTH);
|
|
|
|
strncpy(module->path, path, MODULE__MAX_PATH_LENGTH);
|
|
|
|
strncpy(module->path, path, MODULE__MAX_PATH_LENGTH);
|
|
|
|
|
|
|
|
|
|
|
|
module->argument_count = argument_count;
|
|
|
|
module->argument_count = argument_count;
|
|
|
|
module->stack_size = round_up_to_page(stack_size == 0 ? WASM_STACK_SIZE : stack_size);
|
|
|
|
module->stack_size = round_up_to_page(stack_size == 0 ? WASM_STACK_SIZE : stack_size);
|
|
|
|
module->max_memory = max_memory == 0 ? ((u64)WASM_PAGE_SIZE * WASM_MAX_PAGES) : max_memory;
|
|
|
|
module->max_memory = max_memory == 0 ? ((u64)WASM_PAGE_SIZE * WASM_MAX_PAGES) : max_memory;
|
|
|
|
module->timeout = timeout;
|
|
|
|
module->relative_deadline_us = relative_deadline_us;
|
|
|
|
module->socket_descriptor = -1;
|
|
|
|
module->socket_descriptor = -1;
|
|
|
|
module->port = port;
|
|
|
|
module->port = port;
|
|
|
|
if (request_size == 0) request_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE;
|
|
|
|
if (request_size == 0) request_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE;
|
|
|
|
if (response_size == 0) response_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE;
|
|
|
|
if (response_size == 0) response_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE;
|
|
|
|
module->max_request_size = request_size;
|
|
|
|
module->max_request_size = request_size;
|
|
|
@ -239,6 +239,7 @@ module_new_from_json(char *file_name)
|
|
|
|
i32 response_size = 0;
|
|
|
|
i32 response_size = 0;
|
|
|
|
i32 argument_count = 0;
|
|
|
|
i32 argument_count = 0;
|
|
|
|
u32 port = 0;
|
|
|
|
u32 port = 0;
|
|
|
|
|
|
|
|
u32 relative_deadline_us = 0;
|
|
|
|
i32 is_active = 0;
|
|
|
|
i32 is_active = 0;
|
|
|
|
i32 request_count = 0;
|
|
|
|
i32 request_count = 0;
|
|
|
|
i32 response_count = 0;
|
|
|
|
i32 response_count = 0;
|
|
|
@ -266,6 +267,9 @@ module_new_from_json(char *file_name)
|
|
|
|
argument_count = atoi(val);
|
|
|
|
argument_count = atoi(val);
|
|
|
|
} else if (strcmp(key, "active") == 0) {
|
|
|
|
} else if (strcmp(key, "active") == 0) {
|
|
|
|
is_active = (strcmp(val, "yes") == 0);
|
|
|
|
is_active = (strcmp(val, "yes") == 0);
|
|
|
|
|
|
|
|
} else if (strcmp(key, "relative-deadline-us") == 0) {
|
|
|
|
|
|
|
|
relative_deadline_us = atoi(val);
|
|
|
|
|
|
|
|
printf("Set relative deadline to %d us\n", relative_deadline_us);
|
|
|
|
} else if (strcmp(key, "http-req-headers") == 0) {
|
|
|
|
} else if (strcmp(key, "http-req-headers") == 0) {
|
|
|
|
assert(tokens[i + j + 1].type == JSMN_ARRAY);
|
|
|
|
assert(tokens[i + j + 1].type == JSMN_ARRAY);
|
|
|
|
assert(tokens[i + j + 1].size <= HTTP__MAX_HEADER_COUNT);
|
|
|
|
assert(tokens[i + j + 1].size <= HTTP__MAX_HEADER_COUNT);
|
|
|
@ -310,8 +314,8 @@ module_new_from_json(char *file_name)
|
|
|
|
if (is_active == 0) continue;
|
|
|
|
if (is_active == 0) continue;
|
|
|
|
|
|
|
|
|
|
|
|
// Allocate a module based on the values from the JSON
|
|
|
|
// Allocate a module based on the values from the JSON
|
|
|
|
struct module *module = module_new(module_name, module_path, argument_count, 0, 0, 0, port,
|
|
|
|
struct module *module = module_new(module_name, module_path, argument_count, 0, 0, relative_deadline_us,
|
|
|
|
request_size, response_size);
|
|
|
|
port, request_size, response_size);
|
|
|
|
assert(module);
|
|
|
|
assert(module);
|
|
|
|
module_set_http_info(module, request_count, request_headers, request_content_type, response_count,
|
|
|
|
module_set_http_info(module, request_count, request_headers, request_content_type, response_count,
|
|
|
|
reponse_headers, response_content_type);
|
|
|
|
reponse_headers, response_content_type);
|
|
|
|