gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/rtmp r9753: if the file size is beliow 10M


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9753: if the file size is beliow 10M, load the whole thing into memory.
Date: Wed, 19 Nov 2008 20:28:02 -0700
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9753
committer: address@hidden
branch nick: rtmp
timestamp: Wed 2008-11-19 20:28:02 -0700
message:
  if the file size is beliow 10M, load the whole thing into memory.
modified:
  libnet/http.cpp
=== modified file 'libnet/http.cpp'
--- a/libnet/http.cpp   2008-11-19 20:13:25 +0000
+++ b/libnet/http.cpp   2008-11-20 03:28:02 +0000
@@ -65,6 +65,9 @@
 // FIXME, this seems too small to me.  --gnu
 static const int readsize = 1024;
 
+// max size of files to map enirely into the cache
+static const size_t CACHE_LIMIT = 102400000;
+
 static Cache& cache = Cache::getDefaultInstance();
 
 HTTP::HTTP() 
@@ -279,7 +282,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
 
-    _header << "HTTP/1.1 200 OK" << "\r\n";
+    _header << "HTTP/1.0 200 OK" << "\r\n";
     formatDate();
     formatServer();
 //     if (type == NONE) {
@@ -1607,15 +1610,21 @@
            } else {
                getbytes = filestream->getPagesize();
            }
-           do {
-               boost::uint8_t *ptr = filestream->loadChunk(page);
-               ret = www.writeNet(args->netfd, filestream->get(), getbytes);
-               if (ret <= 0) {
-                   break;
-               }
-               bytes_read += ret;
+           if (filesize >= CACHE_LIMIT) {
+               do {
+                   boost::uint8_t *ptr = filestream->loadChunk(page);
+                   ret = www.writeNet(args->netfd, filestream->get(), 
getbytes);
+                   if (ret <= 0) {
+                       break;
+                   }
+                   bytes_read += ret;
                page += filestream->getPagesize();
-           } while (bytes_read <= filesize);
+               } while (bytes_read <= filesize);
+           } else {
+               boost::uint8_t *ptr = filestream->loadChunk(filesize, 0);
+               ret = www.writeNet(args->netfd, filestream->get(), filesize);
+           }
+           
 #ifdef USE_STATS_CACHE
            struct timespec end;
            clock_gettime (CLOCK_REALTIME, &end);


reply via email to

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