build: remove STANDALONE, SBOX_SCALE_ALLOC, USE_LIBUV flags

main
Sean McBride 5 years ago
parent ae93435e2a
commit b0434ac941

@ -14,10 +14,7 @@ CFLAGS += -DX86_64
#CFLAGS += -DDEBUG
CFLAGS += -D_GNU_SOURCE
#CFLAGS += -DNOSTDIO
#CFLAGS += -DSTANDALONE
CFLAGS += -DUSE_UVIO
CFLAGS += -DUSE_HTTP_UVIO #-DUSE_HTTP_SYNC
CFLAGS += -DSBOX_SCALE_ALLOC
#CFLAGS += -DUSE_SYSCALL
#CFLAGS += -DPREEMPT_DISABLE
CACHE_LINESIZE := $(shell getconf LEVEL1_DCACHE_LINESIZE)

@ -24,8 +24,6 @@ struct module {
u32 refcnt; // ref count how many instances exist here.
// stand-alone vs serverless
#ifndef STANDALONE
struct sockaddr_in srvaddr;
int srvsock, srvport;
// unfortunately, using UV for accepting connections is not great!
@ -40,7 +38,6 @@ struct module {
char rqctype[HTTP_HEADERVAL_MAXSZ];
char rspctype[HTTP_HEADERVAL_MAXSZ];
char resphdrs[HTTP_HEADERS_MAX][HTTP_HEADER_MAXSZ];
#endif
};
struct module *module_alloc(char *mod_name, char *mod_path, i32 nargs, u32 stack_sz, u32 max_heap, u32 timeout,
@ -53,7 +50,6 @@ struct module *module_find_by_sock(int sock);
static inline void
module_http_info(struct module *m, int nrq, char *rqs, char rqtype[], int nrs, char *rs, char rsptype[])
{
#ifndef STANDALONE
assert(m);
m->nreqhdrs = nrq;
m->nresphdrs = nrs;
@ -61,7 +57,6 @@ module_http_info(struct module *m, int nrq, char *rqs, char rqtype[], int nrs, c
memcpy(m->resphdrs, rs, HTTP_HEADER_MAXSZ * HTTP_HEADERS_MAX);
strcpy(m->rqctype, rqtype);
strcpy(m->rspctype, rsptype);
#endif
}
static inline int

@ -58,7 +58,6 @@ struct sandbox {
i32 retval;
struct io_handle handles[SBOX_MAX_OPEN];
#ifndef STANDALONE
struct sockaddr client; // client requesting connection!
int csock;
uv_tcp_t cuv;
@ -66,7 +65,6 @@ struct sandbox {
http_parser hp;
struct http_request rqi;
struct http_response rsi;
#endif
char * read_buf;
ssize_t read_len, read_size;
@ -77,8 +75,6 @@ struct sandbox {
char req_resp_data[1]; // of rr_data_sz, following sandbox mem..
} PAGE_ALIGNED;
#ifndef STANDALONE
#ifdef SBOX_SCALE_ALLOC
struct sandbox_request {
struct module * mod;
char * args;
@ -87,12 +83,6 @@ struct sandbox_request {
unsigned long long int start_time_in_cycles;
};
typedef struct sandbox_request sbox_request_t;
#else
typedef struct sandbox sbox_request_t;
#endif
#else
typedef struct sandbox sbox_request_t;
#endif
DEQUE_PROTOTYPE(sandbox, sbox_request_t *);
@ -116,8 +106,7 @@ sbox_request_alloc(
const struct sockaddr *addr,
unsigned long long int start_time_in_cycles)
{
#ifndef STANDALONE
#ifdef SBOX_SCALE_ALLOC
// sandbox_alloc seems to be
sbox_request_t *s = malloc(sizeof(sbox_request_t));
assert(s);
s->mod = mod;
@ -127,12 +116,6 @@ sbox_request_alloc(
s->start_time_in_cycles = start_time_in_cycles;
sandbox_run(s);
return s;
#else /* SBOX_SCALE_ALLOC */
return sandbox_alloc(mod, args, sock, addr);
#endif
#else /* STANDALONE */
return sandbox_alloc(mod, args, sock, addr);
#endif
}
static inline struct sandbox *

@ -8,56 +8,47 @@ http_parser_settings settings;
static inline int
http_on_msg_begin(http_parser *parser)
{
#ifndef STANDALONE
struct sandbox * s = parser->data;
struct http_request *r = &s->rqi;
r->message_begin = 1;
r->last_was_value = 1; // should always start with a header..
#endif
return 0;
}
static inline int
http_on_msg_end(http_parser *parser)
{
#ifndef STANDALONE
struct sandbox * s = parser->data;
struct http_request *r = &s->rqi;
r->message_end = 1;
#endif
return 0;
}
static inline int
http_on_header_end(http_parser *parser)
{
#ifndef STANDALONE
struct sandbox * s = parser->data;
struct http_request *r = &s->rqi;
r->header_end = 1;
#endif
return 0;
}
static inline int
http_on_url(http_parser *parser, const char *at, size_t length)
{
#ifndef STANDALONE
struct sandbox * s = parser->data;
struct http_request *r = &s->rqi;
assert(strncmp(s->mod->name, (at + 1), length - 1) == 0);
#endif
return 0;
}
static inline int
http_on_header_field(http_parser *parser, const char *at, size_t length)
{
#ifndef STANDALONE
struct sandbox * s = parser->data;
struct http_request *r = &s->rqi;
@ -67,7 +58,6 @@ http_on_header_field(http_parser *parser, const char *at, size_t length)
r->last_was_value = 0;
r->headers[r->nheaders - 1].key = (char *)at; // it is from the sandbox's req_resp_data, should persist.
#endif
return 0;
}
@ -75,7 +65,6 @@ http_on_header_field(http_parser *parser, const char *at, size_t length)
static inline int
http_on_header_value(http_parser *parser, const char *at, size_t length)
{
#ifndef STANDALONE
struct sandbox * s = parser->data;
struct http_request *r = &s->rqi;
@ -84,7 +73,6 @@ http_on_header_value(http_parser *parser, const char *at, size_t length)
assert(length < HTTP_HEADERVAL_MAXSZ);
r->headers[r->nheaders - 1].val = (char *)at; // it is from the sandbox's req_resp_data, should persist.
#endif
return 0;
}
@ -92,7 +80,6 @@ http_on_header_value(http_parser *parser, const char *at, size_t length)
static inline int
http_on_body(http_parser *parser, const char *at, size_t length)
{
#ifndef STANDALONE
struct sandbox * s = parser->data;
struct http_request *r = &s->rqi;
@ -103,7 +90,6 @@ http_on_body(http_parser *parser, const char *at, size_t length)
assert(r->body + r->bodylen == at);
r->bodylen += length;
#endif
return 0;
}
@ -111,20 +97,15 @@ http_on_body(http_parser *parser, const char *at, size_t length)
int
http_request_body_get_sb(struct sandbox *s, char **b)
{
#ifndef STANDALONE
struct http_request *r = &s->rqi;
*b = r->body;
return r->bodylen;
#else
return 0;
#endif
}
int
http_response_header_set_sb(struct sandbox *c, char *key, int len)
{
#ifndef STANDALONE
// by now, req_resp_data should only be containing response!
struct http_response *r = &c->rsi;
@ -132,7 +113,6 @@ http_response_header_set_sb(struct sandbox *c, char *key, int len)
r->nheaders++;
r->headers[r->nheaders - 1].hdr = key;
r->headers[r->nheaders - 1].len = len;
#endif
return 0;
}
@ -140,13 +120,11 @@ http_response_header_set_sb(struct sandbox *c, char *key, int len)
int
http_response_body_set_sb(struct sandbox *c, char *body, int len)
{
#ifndef STANDALONE
struct http_response *r = &c->rsi;
assert(len <= c->mod->max_resp_sz);
r->body = body;
r->bodylen = len;
#endif
return 0;
}
@ -154,12 +132,10 @@ http_response_body_set_sb(struct sandbox *c, char *body, int len)
int
http_response_status_set_sb(struct sandbox *c, char *status, int len)
{
#ifndef STANDALONE
struct http_response *r = &c->rsi;
r->status = status;
r->stlen = len;
#endif
return 0;
}
@ -168,7 +144,6 @@ int
http_response_vector_sb(struct sandbox *c)
{
int nb = 0;
#ifndef STANDALONE
struct http_response *r = &c->rsi;
#ifdef USE_HTTP_UVIO
@ -206,7 +181,6 @@ http_response_vector_sb(struct sandbox *c)
r->bufs[nb].iov_len = 2;
nb++;
}
#endif
#endif
return nb;
@ -215,9 +189,7 @@ http_response_vector_sb(struct sandbox *c)
int
http_request_parse_sb(struct sandbox *s, size_t l)
{
#ifndef STANDALONE
http_parser_execute(&s->hp, &settings, s->req_resp_data + s->rr_data_len, l);
#endif
return 0;
}

@ -1,4 +1,3 @@
#ifdef USE_UVIO
#include <runtime.h>
#include <sandbox.h>
#include <uv.h>
@ -105,10 +104,6 @@ u32
wasm_read(i32 filedes, i32 buf_offset, i32 nbyte)
{
if (filedes == 0) {
#ifdef STANDALONE
char *buf = get_memory_ptr_void(buf_offset, nbyte);
return read(filedes, buf, nbyte);
#else
char * buf = get_memory_ptr_void(buf_offset, nbyte);
struct sandbox * s = sandbox_current();
struct http_request *r = &s->rqi;
@ -118,7 +113,6 @@ wasm_read(i32 filedes, i32 buf_offset, i32 nbyte)
r->bodyrlen += l;
r->bodylen -= l;
return l;
#endif
}
int f = io_handle_fd(filedes);
// TODO: read on other file types
@ -142,10 +136,6 @@ i32
wasm_write(i32 fd, i32 buf_offset, i32 buf_size)
{
if (fd == 1 || fd == 2) {
#ifdef STANDALONE
char *buf = get_memory_ptr_void(buf_offset, buf_size);
return write(fd, buf, buf_size);
#else
char * buf = get_memory_ptr_void(buf_offset, buf_size);
struct sandbox *s = sandbox_current();
int l = s->mod->max_resp_sz - s->rr_data_len;
@ -155,7 +145,6 @@ wasm_write(i32 fd, i32 buf_offset, i32 buf_size)
s->rr_data_len += l;
return l;
#endif
}
int f = io_handle_fd(fd);
// TODO: read on other file types
@ -506,24 +495,6 @@ i32
wasm_readv(i32 fd, i32 iov_offset, i32 iovcnt)
{
if (fd == 0) {
#ifdef STANDALONE
int len = 0, r = 0;
struct wasm_iovec *iov = get_memory_ptr_void(iov_offset, iovcnt * sizeof(struct wasm_iovec));
for (int i = 0; i < iovcnt; i += RDWR_VEC_MAX) {
struct iovec bufs[RDWR_VEC_MAX] = { 0 };
int j = 0;
for (j = 0; j < RDWR_VEC_MAX && i + j < iovcnt; j++) {
bufs[j].iov_base = get_memory_ptr_void(iov[i + j].base_offset, iov[i + j].len);
bufs[j].iov_len = iov[i + j].len;
}
r = readv(fd, bufs, j);
if (r <= 0) break;
len += r;
}
return r < 0 ? r : len;
#else
// both 1 and 2 go to client.
int len = 0;
struct wasm_iovec *iov = get_memory_ptr_void(iov_offset, iovcnt * sizeof(struct wasm_iovec));
@ -542,7 +513,6 @@ wasm_readv(i32 fd, i32 iov_offset, i32 iovcnt)
r->bodyrlen += len;
return len;
#endif
}
// TODO: read on other file types
int gret = 0;
@ -579,7 +549,6 @@ wasm_writev(i32 fd, i32 iov_offset, i32 iovcnt)
{
struct sandbox *c = sandbox_current();
if (fd == 1 || fd == 2) {
#ifndef STANDALONE
// both 1 and 2 go to client.
int len = 0;
struct wasm_iovec *iov = get_memory_ptr_void(iov_offset, iovcnt * sizeof(struct wasm_iovec));
@ -591,22 +560,6 @@ wasm_writev(i32 fd, i32 iov_offset, i32 iovcnt)
}
return len;
#else
for (int i = 0; i < iovcnt; i += RDWR_VEC_MAX) {
struct iovec bufs[RDWR_VEC_MAX] = { 0 };
int j = 0;
for (j = 0; j < RDWR_VEC_MAX && i + j < iovcnt; j++) {
bufs[j].iov_base = get_memory_ptr_void(iov[i + j].base_offset, iov[i + j].len);
bufs[j].iov_len = iov[i + j].len;
}
r = writev(fd, bufs, j);
if (r <= 0) break;
len += r;
}
return r < 0 ? r : len;
#endif
}
// TODO: read on other file types
int d = io_handle_fd(fd);
@ -1193,5 +1146,3 @@ inner_syscall_handler(i32 n, i32 a, i32 b, i32 c, i32 d, i32 e, i32 f)
return 0;
}
#endif

@ -127,41 +127,10 @@ void start_worker_threads(){
exit(-1);
}
void execute_standalone(int argc, char **argv){
arch_context_init(&base_context, 0, 0);
uv_loop_init(&uvio);
int ac = 1;
char *args = argv[1];
if (argc - 1 > 1) {
ac = argc - 1;
char **av = argv + 1;
args = malloc(sizeof(char) * MOD_ARG_MAX_SZ * ac);
memset(args, 0, sizeof(char) * MOD_ARG_MAX_SZ * ac);
for (int i = 0; i < ac; i++) {
char *a = args + (i * MOD_ARG_MAX_SZ * sizeof(char));
strcpy(a, av[i]);
}
}
/* in current dir! */
struct module *m = module_alloc(args, args, ac, 0, 0, 0, 0, 0, 0);
assert(m);
// unsigned long long st = get_time(), en;
struct sandbox *s = sandbox_alloc(m, args, 0, NULL);
// en = get_time();
// fprintf(stderr, "%llu\n", en - st);
exit(0);
}
int
main(int argc, char **argv)
{
printf("Starting Awsm\n");
#ifndef STANDALONE
if (argc != 2) {
usage(argv[0]);
exit(-1);
@ -182,8 +151,4 @@ main(int argc, char **argv)
runtime_thd_init();
start_worker_threads();
#else /* STANDALONE */
execute_standalone();
#endif
}

@ -23,24 +23,18 @@ module_find_by_name(char *name)
struct module *
module_find_by_sock(int sock)
{
#ifndef STANDALONE
int f = __mod_free_off;
for (int i = 0; i < f; i++) {
assert(__mod_db[i]);
if (__mod_db[i]->srvsock == sock) return __mod_db[i];
}
#endif
return NULL;
}
static inline int
module_add(struct module *m)
{
#ifdef STANDALONE
assert(module_find_by_name(m->name) == NULL);
#else
assert(m->srvsock == -1);
#endif
int f = __sync_fetch_and_add(&__mod_free_off, 1);
assert(f < MOD_MAX);
@ -52,7 +46,6 @@ module_add(struct module *m)
static inline void
module_server_init(struct module *m)
{
#ifndef STANDALONE
int fd = socket(AF_INET, SOCK_STREAM, 0);
assert(fd > 0);
m->srvaddr.sin_family = AF_INET;
@ -75,7 +68,6 @@ module_server_init(struct module *m)
accept_evt.events = EPOLLIN;
if (epoll_ctl(epoll_file_descriptor, EPOLL_CTL_ADD, m->srvsock, &accept_evt) < 0) assert(0);
#endif
}
struct module *
@ -111,7 +103,6 @@ module_alloc(char *modname, char *modpath, i32 nargs, u32 stacksz, u32 maxheap,
mod->stack_size = round_up_to_page(stacksz == 0 ? WASM_STACK_SIZE : stacksz);
mod->max_memory = maxheap == 0 ? ((u64)WASM_PAGE_SIZE * WASM_MAX_PAGES) : maxheap;
mod->timeout = timeout;
#ifndef STANDALONE
mod->srvsock = -1;
mod->srvport = port;
if (req_sz == 0) req_sz = MOD_REQ_RESP_DEFAULT;
@ -119,7 +110,6 @@ module_alloc(char *modname, char *modpath, i32 nargs, u32 stacksz, u32 maxheap,
mod->max_req_sz = req_sz;
mod->max_resp_sz = resp_sz;
mod->max_rr_sz = round_up_to_page(req_sz > resp_sz ? req_sz : resp_sz);
#endif
struct indirect_table_entry *cache_tbl = module_indirect_table;
// assumption: modules are created before enabling preemption and before running runtime-sandboxing threads..
@ -150,9 +140,7 @@ module_free(struct module *mod)
if (mod->dl_handle == NULL) return;
if (mod->refcnt) return;
#ifndef STANDALONE
close(mod->srvsock);
#endif
dlclose(mod->dl_handle);
free(mod);
}

@ -51,21 +51,11 @@ sandbox_pull(void)
sbox_request_t *s = sandbox_deque_steal();
if (!s) break;
#ifndef STANDALONE
#ifdef SBOX_SCALE_ALLOC
struct sandbox *sb = sandbox_alloc(s->mod, s->args, s->sock, s->addr);
assert(sb);
free(s);
sb->state = SANDBOX_RUNNABLE;
sandbox_local_run(sb);
#else
assert(s->state == SANDBOX_RUNNABLE);
sandbox_local_run(s);
#endif
#else
assert(s->state == SANDBOX_RUNNABLE);
sandbox_local_run(s);
#endif
n++;
}
@ -77,7 +67,6 @@ static __thread unsigned int in_callback;
void
sandbox_io_nowait(void)
{
#ifdef USE_UVIO
// non-zero if more callbacks are expected
in_callback = 1;
int n = uv_run(runtime_uvio(), UV_RUN_NOWAIT), i = 0;
@ -86,7 +75,6 @@ sandbox_io_nowait(void)
uv_run(runtime_uvio(), UV_RUN_NOWAIT);
}
in_callback = 0;
#endif
// zero, so there is nothing (don't block!)
}
@ -149,7 +137,6 @@ sandbox_schedule_io(void)
void
sandbox_wakeup(sandbox_t *s)
{
#ifndef STANDALONE
softint_disable();
debuglog("[%p: %s]\n", s, s->mod->name);
if (s->state != SANDBOX_BLOCKED) goto done;
@ -159,13 +146,11 @@ sandbox_wakeup(sandbox_t *s)
ps_list_head_append_d(&local_run_queue, s);
done:
softint_enable();
#endif
}
void
sandbox_block(void)
{
#ifndef STANDALONE
assert(in_callback == 0);
softint_disable();
struct sandbox *c = sandbox_current();
@ -175,9 +160,6 @@ sandbox_block(void)
debuglog("[%p: %s, %p: %s]\n", c, c->mod->name, s, s ? s->mod->name : "");
softint_enable();
sandbox_switch(s);
#else
uv_run(runtime_uvio(), UV_RUN_DEFAULT);
#endif
}
void
@ -250,25 +232,17 @@ sandbox_run_func(void *data)
void
sandbox_run(sbox_request_t *s)
{
#ifndef STANDALONE
// for now, a pull model...
// sandbox_run adds to the global ready queue..
// each sandboxing thread pulls off of that global ready queue..
debuglog("[%p: %s]\n", s, s->mod->name);
#ifndef SBOX_SCALE_ALLOC
s->state = SANDBOX_RUNNABLE;
#endif
sandbox_deque_push(s);
#else
sandbox_switch(s);
#endif
}
// perhaps respond to request
void
sandbox_exit(void)
{
#ifndef STANDALONE
struct sandbox *current_sandbox = sandbox_current();
assert(current_sandbox);
softint_disable();
@ -282,9 +256,6 @@ sandbox_exit(void)
munmap(current_sandbox->linear_start, SBOX_MAX_MEM + PAGE_SIZE);
// sandbox_local_end(current_sandbox);
sandbox_switch(n);
#else
sandbox_switch(NULL);
#endif
}
/**
@ -299,7 +270,6 @@ sandbox_exit(void)
void *
runtime_accept_thdfn(void *d)
{
#ifndef STANDALONE
struct epoll_event *epoll_events = (struct epoll_event *)malloc(EPOLL_MAX * sizeof(struct epoll_event));
int total_requests = 0;
while (true) {
@ -331,7 +301,6 @@ runtime_accept_thdfn(void *d)
}
free(epoll_events);
#endif
return NULL;
}

@ -11,11 +11,7 @@ static inline struct sandbox *
sandbox_memory_map(struct module *m)
{
unsigned long mem_sz = SBOX_MAX_MEM; // 4GB
#ifndef STANDALONE
unsigned long sb_sz = sizeof(struct sandbox) + m->max_rr_sz;
#else
unsigned long sb_sz = sizeof(struct sandbox);
#endif
unsigned long lm_sz = WASM_PAGE_SIZE * WASM_START_PAGES;
if (lm_sz + sb_sz > mem_sz) return NULL;
@ -73,7 +69,6 @@ sandbox_args_setup(i32 argc)
static inline void
sb_read_callback(uv_stream_t *s, ssize_t nr, const uv_buf_t *b)
{
#ifndef STANDALONE
struct sandbox *c = s->data;
if (nr > 0) {
@ -85,7 +80,6 @@ sb_read_callback(uv_stream_t *s, ssize_t nr, const uv_buf_t *b)
uv_read_stop(s);
sandbox_wakeup(c);
#endif
}
static inline void
@ -105,7 +99,6 @@ sb_shutdown_callback(uv_shutdown_t *req, int status)
static inline void
sb_write_callback(uv_write_t *w, int status)
{
#ifndef STANDALONE
struct sandbox *c = w->data;
if (status < 0) {
c->cuvsr.data = c;
@ -113,27 +106,21 @@ sb_write_callback(uv_write_t *w, int status)
return;
}
sandbox_wakeup(c);
#endif
}
static inline void
sb_alloc_callback(uv_handle_t *h, size_t suggested, uv_buf_t *buf)
{
struct sandbox *c = h->data;
#ifndef STANDALONE
size_t l = (c->mod->max_rr_sz - c->rr_data_len);
buf->base = (c->req_resp_data + c->rr_data_len);
buf->len = l > suggested ? suggested : l;
#endif
}
static inline int
sandbox_client_request_get(void)
{
#ifndef STANDALONE
struct sandbox *curr = sandbox_current();
curr->rr_data_len = 0;
#ifndef USE_HTTP_UVIO
int r = 0;
@ -160,17 +147,12 @@ sandbox_client_request_get(void)
sandbox_block_http();
if (curr->rr_data_len == 0) return 0;
#endif
return 1;
#else
return 1;
#endif
}
static inline int
sandbox_client_response_set(void)
{
#ifndef STANDALONE
int sndsz = 0;
struct sandbox *curr = sandbox_current();
int rsp_hdr_len = strlen(HTTP_RESP_200OK) + strlen(HTTP_RESP_CONTTYPE) + strlen(HTTP_RESP_CONTLEN);
@ -223,10 +205,7 @@ done:
int r = uv_write(&req, (uv_stream_t *)&curr->cuv, &bufv, 1, sb_write_callback);
sandbox_block_http();
#endif
return 0;
#endif
}
// static inline int
@ -310,16 +289,11 @@ sandbox_entry(void)
f = io_handle_open(2);
assert(f == 2);
#ifndef STANDALONE
http_parser_init(&curr->hp, HTTP_REQUEST);
curr->hp.data = curr;
// NOTE: if more headers, do offset by that!
int rsp_hdr_len = strlen(HTTP_RESP_200OK) + strlen(HTTP_RESP_CONTTYPE) + strlen(HTTP_RESP_CONTLEN);
#ifdef USE_HTTP_UVIO
#ifndef USE_UVIO
printf("UVIO not enabled!\n");
assert(0);
#endif
int r = uv_tcp_init(runtime_uvio(), (uv_tcp_t *)&curr->cuv);
assert(r == 0);
curr->cuv.data = curr;
@ -327,13 +301,8 @@ sandbox_entry(void)
assert(r == 0);
#endif
if (sandbox_client_request_get() > 0)
#endif
{
#ifndef STANDALONE
curr->rr_data_len = rsp_hdr_len; // TODO: do this on first write to body.
#else
curr->rr_data_len = 0;
#endif
alloc_linear_memory();
// perhaps only initialized for the first instance? or TODO!
// module_table_init(curr_mod);
@ -346,13 +315,11 @@ sandbox_entry(void)
sandbox_client_response_set();
}
#ifndef STANDALONE
#ifdef USE_HTTP_UVIO
uv_close((uv_handle_t *)&curr->cuv, sb_close_callback);
sandbox_block_http();
#else
close(curr->csock);
#endif
#endif
sandbox_exit();
}
@ -376,22 +343,12 @@ sandbox_alloc(struct module *mod, char *args, int sock, const struct sockaddr *a
perror("mmap");
assert(0);
}
#ifndef STANDALONE
sb->csock = sock;
if (addr) memcpy(&sb->client, addr, sizeof(struct sockaddr));
#endif
for (int i = 0; i < SBOX_MAX_OPEN; i++) sb->handles[i].fd = -1;
ps_list_init_d(sb);
arch_context_init(&sb->ctxt, (reg_t)sandbox_entry, (reg_t)(sb->stack_start + sb->stack_size));
#ifdef STANDALONE
sandbox_run(sb);
#else
#ifndef SBOX_SCALE_ALLOC
sandbox_run(sb);
#endif
#endif
return sb;
}
@ -408,9 +365,8 @@ sandbox_free(struct sandbox *sb)
if (sb->state != SANDBOX_RETURNED) return;
int sz = sizeof(struct sandbox);
#ifndef STANDALONE
sz += sb->mod->max_rr_sz;
#endif
module_release(sb->mod);
// TODO free(sb->args);

Loading…
Cancel
Save