summaryrefslogtreecommitdiff
path: root/ot_socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_socket.c')
-rw-r--r--ot_socket.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ot_socket.c b/ot_socket.c
index 84020ca..576087f 100644
--- a/ot_socket.c
+++ b/ot_socket.c
@@ -40,14 +40,16 @@ static void ip_from_sockaddr(ot_ip6 ip, uint16_t *port, const struct sockaddr_st
40 } 40 }
41} 41}
42 42
43static int set_nonblocking(int s) { 43int socket_set_blocking(int s, int blocking) {
44 int flags = fcntl(s, F_GETFL, 0); 44 int flags = fcntl(s, F_GETFL, 0);
45 45
46 if (flags == -1) 46 if (flags == -1)
47 return -1; 47 return -1;
48 return fcntl(s, F_SETFL, flags | O_NONBLOCK); 48 return fcntl(s, F_SETFL, blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK));
49} 49}
50 50
51static int set_nonblocking(int s) { return socket_set_blocking(s, 0); }
52
51/* Close without letting the failure we are about to report be overwritten */ 53/* Close without letting the failure we are about to report be overwritten */
52static int close_and_fail(int s) { 54static int close_and_fail(int s) {
53 int saved = errno; 55 int saved = errno;