Remove the binding between current thread and module instance and bugs fix (#131)

Remove wasm_export_api.h that may confuse
Implement wasm_runtime_validate_app_str_addr()
Fix bugs of loader and pass more spec cases

Signed-off-by: Weining Lu <weining.x.lu@intel.com>
This commit is contained in:
Weining
2019-10-11 15:25:23 +08:00
committed by wenyongh
parent bbae4426a0
commit 2a8b1ef454
37 changed files with 496 additions and 552 deletions

View File

@ -18,6 +18,7 @@
#define CONNECTION_LIB_H_
#include "attr_container.h"
#include "wasm_export.h"
#ifdef __cplusplus
extern "C" {
@ -37,7 +38,8 @@ extern "C" {
*
* @return 0~0xFFFFFFFE means id of the connection, otherwise(-1) means fail
*/
typedef uint32 (*connection_open_f)(const char *name, attr_container_t *args);
typedef uint32 (*connection_open_f)(wasm_module_inst_t module_inst,
const char *name, attr_container_t *args);
/*
* @brief Close a connection.

View File

@ -30,7 +30,7 @@ wasm_open_connection(wasm_module_inst_t module_inst,
attr_container_t *args;
char *name, *args_buf;
if (!validate_app_addr(name_offset, 1) ||
if (!validate_app_str_addr(name_offset) ||
!validate_app_addr(args_offset, len) ||
!(name = addr_app_to_native(name_offset)) ||
!(args_buf = addr_app_to_native(args_offset)))
@ -39,7 +39,7 @@ wasm_open_connection(wasm_module_inst_t module_inst,
args = (attr_container_t *)args_buf;
if (connection_impl._open != NULL)
return connection_impl._open(name, args);
return connection_impl._open(module_inst, name, args);
return -1;
}

View File

@ -86,7 +86,8 @@ static struct epoll_event epoll_events[MAX_EVENTS];
/* Buffer to receive data */
static char io_buf[IO_BUF_SIZE];
static uint32 _conn_open(const char *name, attr_container_t *args);
static uint32 _conn_open(wasm_module_inst_t module_inst,
const char *name, attr_container_t *args);
static void _conn_close(uint32 handle);
static int _conn_send(uint32 handle, const char *data, int len);
static bool _conn_config(uint32 handle, attr_container_t *cfg);
@ -217,12 +218,14 @@ static conn_type_t get_conn_type(const char *name)
}
/* --- connection lib function --- */
static uint32 _conn_open(const char *name, attr_container_t *args)
static uint32 _conn_open(wasm_module_inst_t module_inst,
const char *name, attr_container_t *args)
{
int fd;
sys_connection_t *conn;
struct epoll_event ev;
uint32 module_id = app_manager_get_module_id(Module_WASM_App);
uint32 module_id = app_manager_get_module_id(Module_WASM_App,
module_inst);
if (get_app_conns_num(module_id) >= MAX_CONNECTION_PER_APP)
return -1;