gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11797: use select when sniffing byt


From: Rob Savoye
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11797: use select when sniffing bytes from the network interface, rather than a hardcoded delay.
Date: Sun, 24 Jan 2010 10:16:59 -0700
User-agent: Bazaar (2.0.2)

------------------------------------------------------------
revno: 11797
committer: Rob Savoye <address@hidden>
branch nick: trunk
timestamp: Sun 2010-01-24 10:16:59 -0700
message:
  use select when sniffing bytes from the network interface, rather than a 
hardcoded delay.
modified:
  cygnal/cygnal.cpp
  libnet/network.cpp
=== modified file 'cygnal/cygnal.cpp'
--- a/cygnal/cygnal.cpp 2010-01-22 05:22:12 +0000
+++ b/cygnal/cygnal.cpp 2010-01-24 17:16:59 +0000
@@ -862,7 +862,6 @@
                do {
                    buf = hand->parseFirstRequest(args->netfd, Network::HTTP);
                    if (!buf) {
-                       gnashSleep(10);
                        retries--;
                        continue;
                    } else {
@@ -1146,7 +1145,7 @@
        // Wait for something from one of the file descriptors. This timeout
        // is the time between sending packets to the client when there is
        // no client input, which effects the streaming speed of big files.
-       net.setTimeout(15);
+       net.setTimeout(5);
        hits = net.waitForNetData(hand->getClients());
        if (FD_ISSET(0, &hits)) {
            FD_CLR(0, &hits);

=== modified file 'libnet/network.cpp'
--- a/libnet/network.cpp        2010-01-20 17:21:41 +0000
+++ b/libnet/network.cpp        2010-01-24 17:16:59 +0000
@@ -358,13 +358,13 @@
         }
 
         if (ret == -1) {
-            log_debug(_("The accept() socket for fd #%d never was available 
for writing"), fd);
+            log_debug(_("The accept() socket for fd #%d never was available"), 
fd);
             return -1;
         }
 
         if (ret == 0) {
             if (_debug) {
-                log_debug(_("The accept() socket for fd #%d timed out waiting 
to write"), fd);
+                log_debug(_("The accept() socket for fd #%d timed out 
waitingfor data"), fd);
                return 0;
             }
         }
@@ -1602,12 +1602,23 @@
     // GNASH_REPORT_FUNCTION;
 
     int bytes = 0;
+    fd_set fdset;
+
+    FD_SET(fd, &fdset);
+
+    struct timeval tval;
+    tval.tv_sec = 0;
+    tval.tv_usec = 10;
+    if (select(fd+1, &fdset, NULL, NULL, &tval)) {
+       if (FD_ISSET(fd, &fdset)) {
 #ifndef _WIN32
-    ioctl(fd, FIONREAD, &bytes);
-    log_network("#%d bytes waiting in kernel network buffer.", bytes);
+           ioctl(fd, FIONREAD, &bytes);
 #else
-    log_unimpl("Network::sniffBytesReady(win32 equivalant)");
+           ioctlSocket(fd, FIONREAD, &bytes);
 #endif
+           log_network("#%d bytes waiting in kernel network buffer.", bytes);
+       }
+    }
     
     return bytes;
 }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]