Skip to content

Commit 87732f2

Browse files
srberarddkouba-atym
authored andcommitted
Fix several issues (#4377)
* Directory support WIP. readdir works but I think we have a memory leak somewhere * Fix: always use standard stream fds. Fix unlinkat and renameat. fd 0, 1, and 2 will always be supplied for standard streams. Unlinkat and renameat work exclusively based on supplied paths. * Fix: use macro for free() * Added a temporary workaround for issue identified in PR#4377 * Fixed reference to file descriptor and cleaned up dead/commented code. Signed-off-by: Stephen Berard <[email protected]> Co-authored-by: Dan Kouba <[email protected]>
1 parent 150122b commit 87732f2

File tree

4 files changed

+248
-146
lines changed

4 files changed

+248
-146
lines changed

core/iwasm/common/wasm_application.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
289289
exec_env = wasm_runtime_get_exec_env_singleton(module_inst);
290290
if (exec_env) {
291291
wasm_runtime_dump_mem_consumption(exec_env);
292-
(WASMModuleInstance *)module_inst->cur_exception
293292
}
294293
#endif
295294

core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,9 +2210,16 @@ wasmtime_ssp_poll_oneoff(wasm_exec_env_t exec_env, struct fd_table *curfds,
22102210
fd_object_get_locked(&fos[i], ft, s->u.u.fd_readwrite.fd,
22112211
__WASI_RIGHT_POLL_FD_READWRITE, 0);
22122212
if (error == 0) {
2213+
2214+
// Temporary workaround (see PR#4377)
2215+
#ifdef BH_PLATFORM_ZEPHYR
2216+
os_file_handle tfd = fos[i]->file_handle->fd;
2217+
#else
2218+
os_file_handle tfd = fos[i]->file_handle;
2219+
#endif
22132220
// Proper file descriptor on which we can poll().
22142221
pfds[i] = (os_poll_file_handle){
2215-
.fd = fos[i]->file_handle->fd,
2222+
.fd = tfd,
22162223
.events = s->u.type == __WASI_EVENTTYPE_FD_READ
22172224
? POLLIN
22182225
: POLLOUT,
@@ -2854,13 +2861,10 @@ wasmtime_ssp_sock_recv_from(wasm_exec_env_t exec_env, struct fd_table *curfds,
28542861
}
28552862

28562863
// If the source address is not NULL, the caller is requesting the source
2857-
// address to be returned if the protocol supports it. As such, we convert
2858-
// the format of the structure pass in prior to the call to the OS
2859-
// implementation. If the value is NULL, the POSIX standard states that
2860-
// the address is not returned.
2864+
// address to be returned if the protocol supports it. If the value is
2865+
// NULL, the POSIX standard states that the address is not returned.
28612866
if (src_addr != NULL) {
28622867
sockaddr_ptr = &sockaddr;
2863-
wasi_addr_to_bh_sockaddr(src_addr, &sockaddr);
28642868
}
28652869

28662870
/* Consume bh_sockaddr_t instead of __wasi_addr_t */

core/shared/platform/zephyr/platform_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ typedef struct zephyr_fs_desc {
251251
};
252252
bool is_dir;
253253
bool used;
254+
uint32_t dir_index; // DSK: supprt for rewind and seek
254255
} zephyr_fs_desc;
255256

256257
// definition of zephyr_handle

0 commit comments

Comments
 (0)