summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/socket-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore/socket-util.c')
-rw-r--r--src/pulsecore/socket-util.c69
1 files changed, 25 insertions, 44 deletions
diff --git a/src/pulsecore/socket-util.c b/src/pulsecore/socket-util.c
index b7361e90..085edeb8 100644
--- a/src/pulsecore/socket-util.c
+++ b/src/pulsecore/socket-util.c
@@ -143,83 +143,64 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
pa_snprintf(c, l, "Unknown client");
}
-int pa_socket_low_delay(int fd) {
+void pa_make_socket_low_delay(int fd) {
#ifdef SO_PRIORITY
int priority;
pa_assert(fd >= 0);
priority = 6;
- if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, (void*)&priority, sizeof(priority)) < 0) {
+ if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, (void*)&priority, sizeof(priority)) < 0)
pa_log_warn("SO_PRIORITY failed: %s", pa_cstrerror(errno));
- return -1;
- }
#endif
-
- return 0;
}
-int pa_socket_tcp_low_delay(int fd) {
- int ret, tos, on;
-
+void pa_make_tcp_socket_low_delay(int fd) {
pa_assert(fd >= 0);
-
- ret = pa_socket_low_delay(fd);
-
- on = 1;
- tos = 0;
+
+ pa_make_socket_low_delay(fd);
#if defined(SOL_TCP) || defined(IPPROTO_TCP)
+ {
+ int on = 1;
#if defined(SOL_TCP)
- if (setsockopt(fd, SOL_TCP, TCP_NODELAY, (void*)&on, sizeof(on)) < 0)
+ if (setsockopt(fd, SOL_TCP, TCP_NODELAY, (void*)&on, sizeof(on)) < 0)
#else
- if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on)) < 0)
+ if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on)) < 0)
#endif
- {
- pa_log_warn("TCP_NODELAY failed: %s", pa_cstrerror(errno));
- ret = -1;
+ pa_log_warn("TCP_NODELAY failed: %s", pa_cstrerror(errno));
}
#endif
-
+
#if defined(IPTOS_LOWDELAY) && defined(IP_TOS) && (defined(SOL_IP) || defined(IPPROTO_IP))
- tos = IPTOS_LOWDELAY;
+ {
+ int tos = IPTOS_LOWDELAY;
#ifdef SOL_IP
- if (setsockopt(fd, SOL_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
+ if (setsockopt(fd, SOL_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
#else
- if (setsockopt(fd, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
+ if (setsockopt(fd, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
#endif
- {
- pa_log_warn("IP_TOS failed: %s", pa_cstrerror(errno));
- ret = -1;
+ pa_log_warn("IP_TOS failed: %s", pa_cstrerror(errno));
}
#endif
-
- return ret;
}
-int pa_socket_udp_low_delay(int fd) {
- int ret, tos;
-
+void pa_make_udp_socket_low_delay(int fd) {
pa_assert(fd >= 0);
-
- ret = pa_socket_low_delay(fd);
-
- tos = 0;
-
+
+ pa_make_socket_low_delay(fd);
+
#if defined(IPTOS_LOWDELAY) && defined(IP_TOS) && (defined(SOL_IP) || defined(IPPROTO_IP))
- tos = IPTOS_LOWDELAY;
+ {
+ int tos = IPTOS_LOWDELAY;
#ifdef SOL_IP
- if (setsockopt(fd, SOL_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
+ if (setsockopt(fd, SOL_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
#else
- if (setsockopt(fd, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
+ if (setsockopt(fd, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
#endif
- {
- ret = -1;
- pa_log_warn("IP_TOS failed: %s", pa_cstrerror(errno));
+ pa_log_warn("IP_TOS failed: %s", pa_cstrerror(errno));
}
#endif
-
- return ret;
}
int pa_socket_set_rcvbuf(int fd, size_t l) {