summaryrefslogtreecommitdiffstats
path: root/src/socket.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-30 03:32:36 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-30 03:32:36 +0200
commit0d0a857c696b653a65c709bbfb11bdaff67369b8 (patch)
treee1c26da2053f8b4801b5120517b16838b7a66c32 /src/socket.c
parent4f082c7df3998cdc2cdf9845a62d886d05257cb8 (diff)
downloadfastd-0d0a857c696b653a65c709bbfb11bdaff67369b8.tar
fastd-0d0a857c696b653a65c709bbfb11bdaff67369b8.zip
Use SOCK_NONBLOCK where available
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/socket.c b/src/socket.c
index d49888c..340967c 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -33,7 +33,7 @@ static int bind_socket(const fastd_bind_address_t *addr, bool warn) {
int af = AF_UNSPEC;
if (addr->addr.sa.sa_family != AF_INET) {
- fd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+ fd = socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_UDP);
if (fd >= 0) {
af = AF_INET6;
@@ -46,7 +46,7 @@ static int bind_socket(const fastd_bind_address_t *addr, bool warn) {
}
}
if (fd < 0 && addr->addr.sa.sa_family != AF_INET6) {
- fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ fd = socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_UDP);
if (fd < 0)
exit_errno("unable to create socket");
else
@@ -56,7 +56,9 @@ static int bind_socket(const fastd_bind_address_t *addr, bool warn) {
if (fd < 0)
goto error;
- fastd_setfl(fd, O_NONBLOCK);
+#ifdef NO_HAVE_SOCK_NONBLOCK
+ fastd_setnonblock(fd);
+#endif
int one = 1;