You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2017/05/17 09:55:25 UTC
[09/43] incubator-mynewt-core git commit: MYNEWT-745 Make native
sockets nonblocking.
MYNEWT-745 Make native sockets nonblocking.
This prevents deadlock in the "no-signals" sim implementation.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/71811d43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/71811d43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/71811d43
Branch: refs/heads/bluetooth5
Commit: 71811d438c1c4722c09419646c4e6f198da1d1b2
Parents: cc1acfe
Author: Christopher Collins <cc...@apache.org>
Authored: Tue May 9 18:05:53 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue May 9 18:05:53 2017 -0700
----------------------------------------------------------------------
net/ip/native_sockets/src/native_sock.c | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/71811d43/net/ip/native_sockets/src/native_sock.c
----------------------------------------------------------------------
diff --git a/net/ip/native_sockets/src/native_sock.c b/net/ip/native_sockets/src/native_sock.c
index 9e2d3d6..e0ecd79 100644
--- a/net/ip/native_sockets/src/native_sock.c
+++ b/net/ip/native_sockets/src/native_sock.c
@@ -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;