chiark / gitweb /
never reduce socket buffers
authorrjk@greenend.org.uk <>
Sun, 23 Sep 2007 15:17:30 +0000 (16:17 +0100)
committerrjk@greenend.org.uk <>
Sun, 23 Sep 2007 15:17:30 +0000 (16:17 +0100)
clients/playrtp.c
server/speaker.c

index 0b25c89..fb897ce 100644 (file)
@@ -920,7 +920,7 @@ int main(int argc, char **argv) {
   len = sizeof rcvbuf;
   if(getsockopt(rtpfd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, &len) < 0)
     fatal(errno, "error calling getsockopt SO_RCVBUF");
-  if(target_rcvbuf) {
+  if(target_rcvbuf > rcvbuf) {
     if(setsockopt(rtpfd, SOL_SOCKET, SO_RCVBUF,
                   &target_rcvbuf, sizeof target_rcvbuf) < 0)
       error(errno, "error calling setsockopt SO_RCVBUF %d", 
index 5d20394..37719f9 100644 (file)
@@ -965,12 +965,16 @@ int main(int argc, char **argv) {
     if(getsockopt(bfd, SOL_SOCKET, SO_SNDBUF,
                   &sndbuf, &len) < 0)
       fatal(errno, "error getting SO_SNDBUF");
-    if(setsockopt(bfd, SOL_SOCKET, SO_SNDBUF,
-                  &target_sndbuf, sizeof target_sndbuf) < 0)
-      error(errno, "error setting SO_SNDBUF to %d", target_sndbuf);
-    else
-      info("changed socket send buffer size from %d to %d",
-           sndbuf, target_sndbuf);
+    if(target_sndbuf > sndbuf) {
+      if(setsockopt(bfd, SOL_SOCKET, SO_SNDBUF,
+                    &target_sndbuf, sizeof target_sndbuf) < 0)
+        error(errno, "error setting SO_SNDBUF to %d", target_sndbuf);
+      else
+        info("changed socket send buffer size from %d to %d",
+             sndbuf, target_sndbuf);
+    } else
+        info("default socket send buffer is %d",
+             sndbuf);
     /* We might well want to set additional broadcast- or multicast-related
      * options here */
     if(sres && bind(bfd, sres->ai_addr, sres->ai_addrlen) < 0)