Make native sockets nonblocking.
This prevents deadlock in the "no-signals" sim implementation.
@@ -250,6 +250,7 @@ native_sock_create(struct mn_socket **sp, uint8_t domain,
struct native_sock_state *nss = &native_sock_state;
struct native_sock *ns;
int idx;
+ int rc;
switch (domain) {
case MN_PF_INET:
@@ -283,6 +284,11 @@ native_sock_create(struct mn_socket **sp, uint8_t domain,
}
os_sem_init(&ns->ns_sem, 0);
idx = socket(domain, type, proto);
+
+ /* Make the socket nonblocking. */
+ rc = fcntl(idx, F_SETFL, fcntl(idx, F_GETFL, 0) | O_NONBLOCK);
+ assert(rc == 0);
+
ns->ns_fd = idx;
ns->ns_pf = domain;
ns->ns_type = type;
