예제 #1
0
파일: ss.cs 프로젝트: lazebird/rabbit
        public void write_file(string filename)
        {
            FileStream fs = new FileStream(sdic["cwd"] + filename, FileMode.Create, FileAccess.Write, FileShare.Read);

            this.filename = filename;
            this.q        = new rqueue(idic["qsize"], idic["qtout"]);
            if (bdic["fslog"])
            {
                t = new Thread(() => rfs.writestream_log(fs, this.q, this.filename, slog));
            }
            else
            {
                t = new Thread(() => rfs.writestream(fs, this.q, this.filename));
            }
            t.IsBackground = true;
            t.Start();
        }
예제 #2
0
파일: ss.cs 프로젝트: lazebird/rabbit
 protected virtual void Dispose(bool disposing)
 {
     if (q != null)
     {
         q.Dispose();
     }
     if (t != null)
     {
         t.Abort();
     }
     q = null;
     t = null;
     if (!disposing)
     {
         return;
     }
     request  = null;
     response = null;
 }
예제 #3
0
파일: ss.cs 프로젝트: lazebird/rabbit
        public void read_file(string filename)
        {
            FileStream fs = new FileStream(sdic["cwd"] + filename, FileMode.Open, FileAccess.Read);

            this.filename = filename;
            this.filesize = fs.Length;
            this.q        = new rqueue(idic["qsize"], idic["qtout"]);
            maxblkno      = (int)(this.filesize + idic["blksize"]) / idic["blksize"]; // if len % blksize = 0, an empty data pkt sent at last
            if (bdic["fslog"])
            {
                t = new Thread(() => rfs.readstream_log(fs, this.q, idic["blksize"], this.filename, slog));
            }
            else
            {
                t = new Thread(() => rfs.readstream(fs, this.q, idic["blksize"]));
            }
            t.IsBackground = true;
            t.Start();
        }
예제 #4
0
파일: ss.cs 프로젝트: lazebird/rabbit
 protected virtual void Dispose(bool disposing)
 {
     if (q != null)
     {
         q.Dispose();
     }
     if (uc != null)
     {
         uc.Close();
     }
     q  = null;
     uc = null;
     if (!disposing)
     {
         return;
     }
     r      = null;
     pktbuf = null;
 }
예제 #5
0
파일: ss.cs 프로젝트: lazebird/rabbit
        void loadfile(Hashtable mimehash, string path)
        {
            if (loadvideo(mimehash, path))
            {
                return;
            }
            Stream output = response.OutputStream;

            response.ContentType = uri2mime(mimehash, path);
            log("I: file " + path + " mime " + response.ContentType);
            FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);

            response.ContentLength64 = fs.Length;
            q = new rqueue(10000);                              // 10000 * 10K, max memory used 100M
            t = new Thread(() => rfs.readstream(fs, q, 10000)); // 10000, max block size 10K, avoid LOH problem
            t.IsBackground = true;
            t.Start();
            rfs.writestream(output, q, fs.Name);
            t.Abort();
            q.Dispose();
        }