|
|
@ -101,7 +101,8 @@ module_server_init(struct module *module)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Module Mega Setup Function
|
|
|
|
* Module Mega Setup Function
|
|
|
|
* Creates a new module, invokes tbl_init_fn to initialize the indirect table, adds it to the module DB, and starts listening for HTTP Requests
|
|
|
|
* Creates a new module, invokes tbl_init_fn to initialize the indirect table, adds it to the module DB, and starts
|
|
|
|
|
|
|
|
*listening for HTTP Requests
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param name
|
|
|
|
* @param name
|
|
|
|
* @param path
|
|
|
|
* @param path
|
|
|
@ -114,8 +115,8 @@ module_server_init(struct module *module)
|
|
|
|
* @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_alloc(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_memory, u32 timeout, int port, int request_size,
|
|
|
|
module_alloc(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_memory, u32 timeout, int port,
|
|
|
|
int response_size)
|
|
|
|
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;
|
|
|
@ -156,18 +157,20 @@ module_alloc(char *name, char *path, i32 argument_count, u32 stack_size, u32 max
|
|
|
|
if (response_size == 0) response_size = MOD_REQ_RESP_DEFAULT;
|
|
|
|
if (response_size == 0) response_size = MOD_REQ_RESP_DEFAULT;
|
|
|
|
module->max_request_size = request_size;
|
|
|
|
module->max_request_size = request_size;
|
|
|
|
module->max_response_size = response_size;
|
|
|
|
module->max_response_size = response_size;
|
|
|
|
module->max_request_or_response_size = round_up_to_page(request_size > response_size ? request_size : response_size);
|
|
|
|
module->max_request_or_response_size = round_up_to_page(request_size > response_size ? request_size
|
|
|
|
|
|
|
|
: response_size);
|
|
|
|
|
|
|
|
|
|
|
|
// module_indirect_table is a thread-local struct
|
|
|
|
// module_indirect_table is a thread-local struct
|
|
|
|
struct indirect_table_entry *cache_tbl = module_indirect_table;
|
|
|
|
struct indirect_table_entry *cache_tbl = module_indirect_table;
|
|
|
|
|
|
|
|
|
|
|
|
// assumption: All modules are created at program start before we enable preemption or enable the execution of any worker threads
|
|
|
|
// assumption: All modules are created at program start before we enable preemption or enable the execution of
|
|
|
|
// We are checking that thread-local module_indirect_table is NULL to prove that we aren't yet preempting
|
|
|
|
// any worker threads We are checking that thread-local module_indirect_table is NULL to prove that we aren't
|
|
|
|
// If we want to be able to do this later, we can possibly defer module_table_init until the first invocation
|
|
|
|
// yet preempting If we want to be able to do this later, we can possibly defer module_table_init until the
|
|
|
|
|
|
|
|
// first invocation
|
|
|
|
assert(cache_tbl == NULL);
|
|
|
|
assert(cache_tbl == NULL);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: determine why we have to set the module_indirect_table state before calling table init and then restore the existing value
|
|
|
|
// TODO: determine why we have to set the module_indirect_table state before calling table init and then restore
|
|
|
|
// What is the relationship between these things?
|
|
|
|
// the existing value What is the relationship between these things?
|
|
|
|
module_indirect_table = module->indirect_table;
|
|
|
|
module_indirect_table = module->indirect_table;
|
|
|
|
module_table_init(module);
|
|
|
|
module_table_init(module);
|
|
|
|
module_indirect_table = cache_tbl;
|
|
|
|
module_indirect_table = cache_tbl;
|
|
|
|