diff --git a/patches/tinyemu/tinyemu/slirp/misc.c b/patches/tinyemu/tinyemu/slirp/misc.c index 7a79cdb..2c53eb9 100644 --- a/patches/tinyemu/tinyemu/slirp/misc.c +++ b/patches/tinyemu/tinyemu/slirp/misc.c @@ -234,8 +234,10 @@ fork_exec(struct socket *so, const char *ex, int do_pty) closesocket(s); opt = 1; setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); +#ifndef WASI opt = 1; setsockopt(so->s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); +#endif } fd_nonblock(so->s); diff --git a/patches/tinyemu/tinyemu/slirp/socket.c b/patches/tinyemu/tinyemu/slirp/socket.c index 1ba8ae1..06bd028 100644 --- a/patches/tinyemu/tinyemu/slirp/socket.c +++ b/patches/tinyemu/tinyemu/slirp/socket.c @@ -635,7 +635,10 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, #endif return NULL; } + +#ifndef WASI setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); +#endif getsockname(s,(struct sockaddr *)&addr,&addrlen); so->so_fport = addr.sin_port; diff --git a/patches/tinyemu/tinyemu/slirp/tcp_input.c b/patches/tinyemu/tinyemu/slirp/tcp_input.c index 53dbc87..ee1e5a9 100644 --- a/patches/tinyemu/tinyemu/slirp/tcp_input.c +++ b/patches/tinyemu/tinyemu/slirp/tcp_input.c @@ -578,7 +578,13 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso) goto cont_input; } - if((tcp_fconnect(so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) { +#ifdef WASI + if((tcp_fconnect(so) == 0)) { + goto cont_conn; + } +#else + if((tcp_fconnect(so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) + { u_char code=ICMP_UNREACH_NET; DEBUG_MISC((dfd," tcp fconnect errno = %d-%s\n", errno,strerror(errno))); @@ -612,7 +618,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso) tp->t_state = TCPS_SYN_RECEIVED; } return; - +#endif cont_conn: /* m==NULL * Check if the connect succeeded diff --git a/patches/tinyemu/tinyemu/slirp/tcp_subr.c b/patches/tinyemu/tinyemu/slirp/tcp_subr.c index 1557e89..5a91d3b 100644 --- a/patches/tinyemu/tinyemu/slirp/tcp_subr.c +++ b/patches/tinyemu/tinyemu/slirp/tcp_subr.c @@ -332,8 +332,10 @@ int tcp_fconnect(struct socket *so) fd_nonblock(s); opt = 1; setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(opt )); +#ifndef WASI opt = 1; setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(opt )); +#endif addr.sin_family = AF_INET; if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) == @@ -355,11 +357,16 @@ int tcp_fconnect(struct socket *so) /* We don't care what port we get */ ret = connect(s,(struct sockaddr *)&addr,sizeof (addr)); + if (ret == 0) { + soisfconnected(so); + } else + { /* * If it's not in progress, it failed, so we just return 0, * without clearing SS_NOFDREF */ - soisfconnecting(so); + soisfconnecting(so); + } } return(ret); @@ -420,8 +427,10 @@ tcp_connect(struct socket *inso) fd_nonblock(s); opt = 1; setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); +#ifndef WASI opt = 1; setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); +#endif opt = 1; setsockopt(s,IPPROTO_TCP,TCP_NODELAY,(char *)&opt,sizeof(int));