[xiph-commits] r15766 - in icecast/trunk: icecast/src net

karl at svn.xiph.org karl at svn.xiph.org
Sat Mar 14 09:05:14 PDT 2009


Author: karl
Date: 2009-03-14 09:05:12 -0700 (Sat, 14 Mar 2009)
New Revision: 15766

Modified:
   icecast/trunk/icecast/src/cfgfile.c
   icecast/trunk/icecast/src/cfgfile.h
   icecast/trunk/icecast/src/connection.c
   icecast/trunk/net/sock.c
   icecast/trunk/net/sock.h
Log:
non-blocking setting on win32 broke with previous patch. Add optional xml setting for
specifying the TCP send buffer size, it seems that on at least some win32 systems,
the window size stays at 8k (even with registry settings) which could limit available
streaming bandwidth.


Modified: icecast/trunk/icecast/src/cfgfile.c
===================================================================
--- icecast/trunk/icecast/src/cfgfile.c	2009-03-14 13:07:57 UTC (rev 15765)
+++ icecast/trunk/icecast/src/cfgfile.c	2009-03-14 16:05:12 UTC (rev 15766)
@@ -821,6 +821,11 @@
             listener->bind_address = (char *)xmlNodeListGetString(doc, 
                     node->xmlChildrenNode, 1);
         }
+        else if (xmlStrcmp (node->name, XMLSTR("so-sndbuf")) == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            listener->so_sndbuf = atoi(tmp);
+            if(tmp) xmlFree(tmp);
+        }
     } while ((node = node->next));
 
     /* we know there's at least one of these, so add this new one after the first

Modified: icecast/trunk/icecast/src/cfgfile.h
===================================================================
--- icecast/trunk/icecast/src/cfgfile.h	2009-03-14 13:07:57 UTC (rev 15765)
+++ icecast/trunk/icecast/src/cfgfile.h	2009-03-14 16:05:12 UTC (rev 15766)
@@ -101,6 +101,7 @@
 typedef struct _listener_t {
     struct _listener_t *next;
     int port;
+    int so_sndbuf;
     char *bind_address;
     int shoutcast_compat;
     char *shoutcast_mount;

Modified: icecast/trunk/icecast/src/connection.c
===================================================================
--- icecast/trunk/icecast/src/connection.c	2009-03-14 13:07:57 UTC (rev 15765)
+++ icecast/trunk/icecast/src/connection.c	2009-03-14 16:05:12 UTC (rev 15766)
@@ -1404,6 +1404,9 @@
                 sock_close (sock);
                 break;
             }
+            /* some win32 setups do not do TCP win scaling well, so allow an override */
+            if (listener->so_sndbuf)
+                sock_set_send_buffer (sock, listener->so_sndbuf);
             sock_set_blocking (sock, 0);
             successful = 1;
             global.serversock [count] = sock;

Modified: icecast/trunk/net/sock.c
===================================================================
--- icecast/trunk/net/sock.c	2009-03-14 13:07:57 UTC (rev 15765)
+++ icecast/trunk/net/sock.c	2009-03-14 16:05:12 UTC (rev 15766)
@@ -217,7 +217,7 @@
     l = recv (sock, &c, 1, MSG_PEEK);
     if (l == 0)
         return 0;
-    if (l < 0 && sock_recoverable (sock_error()))
+    if (l == SOCK_ERROR && sock_recoverable (sock_error()))
         return 1;
     return 0;
 }
@@ -251,9 +251,9 @@
 {
 #ifdef _WIN32
 #ifdef __MINGW32__
-    u_long varblock = block;
+    u_long varblock = 1;
 #else
-    int varblock = block;
+    int varblock = 1;
 #endif
 #endif
 
@@ -261,6 +261,7 @@
         return SOCK_ERROR;
 
 #ifdef _WIN32
+    if (block) varblock = 0;
     return ioctlsocket(sock, FIONBIO, &varblock);
 #else
     return fcntl(sock, F_SETFL, (block) ? 0 : O_NONBLOCK);
@@ -892,6 +893,11 @@
 
 #endif
 
+void sock_set_send_buffer (sock_t sock, int win_size)
+{
+    setsockopt (sock, SOL_SOCKET, SO_SNDBUF, (char *) &win_size, sizeof(win_size));
+}
+
 int sock_listen(sock_t serversock, int backlog)
 {
     if (!sock_valid_socket(serversock))

Modified: icecast/trunk/net/sock.h
===================================================================
--- icecast/trunk/net/sock.h	2009-03-14 13:07:57 UTC (rev 15765)
+++ icecast/trunk/net/sock.h	2009-03-14 16:05:12 UTC (rev 15766)
@@ -95,6 +95,7 @@
 # define sock_read_line _mangle(sock_read_line)
 # define sock_get_server_socket _mangle(sock_get_server_socket)
 # define sock_listen _mangle(sock_listen)
+# define sock_set_send_buffer _mangle(sock_set_send_buffer)
 # define sock_accept _mangle(sock_accept)
 #endif
 
@@ -107,10 +108,11 @@
 int sock_stalled(int error);
 int sock_valid_socket(sock_t sock);
 int sock_active (sock_t sock);
-int sock_set_blocking(sock_t sock, const int block);
+int sock_set_blocking(sock_t sock, int block);
 int sock_set_nolinger(sock_t sock);
 int sock_set_keepalive(sock_t sock);
 int sock_set_nodelay(sock_t sock);
+void sock_set_send_buffer (sock_t sock, int win_size);
 void sock_set_error(int val);
 int sock_close(sock_t  sock);
 



More information about the commits mailing list