From ea0accdadfa7974055b0398e08f05ec427d2a0f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Wed, 17 Jul 2013 19:51:09 +0200 Subject: [PATCH] Fix indent --- src/fd_utils.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fd_utils.c b/src/fd_utils.c index 20c158d..a3e65c8 100644 --- a/src/fd_utils.c +++ b/src/fd_utils.c @@ -10,9 +10,11 @@ int uc_set_nonblocking(int fd) { int flags = fcntl(fd,F_GETFL,NULL); + if(flags < 0 ) { return flags; } + return fcntl(fd,F_SETFL,flags | O_NONBLOCK); } @@ -30,7 +32,6 @@ int uc_set_reuseaddr(int sockfd) { int opt = 1; return setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)); - } int uc_set_tcp_keepalive(int sockfd) @@ -51,7 +52,6 @@ int uc_set_tcp_keepalive_cfg(int sockfd, const struct UCKeepConfig *cfg) } //set the keepalive options - rc = setsockopt(sockfd, SOL_TCP, TCP_KEEPCNT, &cfg->keepcnt, sizeof cfg->keepcnt); if (rc != 0) { return rc; @@ -70,7 +70,6 @@ int uc_set_tcp_keepalive_cfg(int sockfd, const struct UCKeepConfig *cfg) return 0; } - int uc_set_send_timeout(int sockfd,long timeoutms) { struct timeval so_sndtimeo = {timeoutms/1000,(timeoutms%1000)*1000}; @@ -85,15 +84,18 @@ int uc_set_receive_timeout(int sockfd,long timeoutms) return setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &so_sndtimeo, sizeof(so_sndtimeo)); } -int uc_set_ip_dscp(int fd, unsigned int dscp) { +int uc_set_ip_dscp(int fd, unsigned int dscp) +{ int val; + //only 6 bits for dscp if (dscp > 63) { errno = EINVAL; return -1; } val = dscp << 2; + return setsockopt(fd, IPPROTO_IP, IP_TOS, &val, sizeof val); }