[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/cygnal buffer.h http.h buffer.cpp cque.cp...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash/cygnal buffer.h http.h buffer.cpp cque.cp... |
Date: |
Thu, 20 Mar 2008 02:25:57 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 08/03/20 02:25:57
Modified files:
cygnal : buffer.h http.h buffer.cpp cque.cpp cygnal.cpp
handler.cpp http.cpp ChangeLog
Log message:
* buffer.{h,cpp}: Add support for optional performance testing
statistics
* cque.cpp: Set the returned buffer to zero if the mutex has an
error.
* cygnal.cpp: Rn forever, restarting connections after the
disconnect.
* handler.cpp: Trap mutex errors.
* http.cpp: Tweak the handling of persistant connections. Add
statistics gathering.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/buffer.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.h?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/buffer.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/cque.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/cygnal.cpp?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/handler.cpp?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/ChangeLog?cvsroot=gnash&r1=1.10&r2=1.11
Patches:
Index: buffer.h
===================================================================
RCS file: /sources/gnash/gnash/cygnal/buffer.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- buffer.h 18 Mar 2008 22:04:28 -0000 1.3
+++ buffer.h 20 Mar 2008 02:25:57 -0000 1.4
@@ -21,6 +21,8 @@
#include <boost/cstdint.hpp>
#include <string>
+#include <time.h>
+
#include "network.h"
// _definst_ is the default instance name
@@ -67,6 +69,9 @@
void *init(size_t nbytes);
gnash::Network::byte_t *_ptr;
int _nbytes;
+#if USE_STATISTICS
+ struct timespec _stamp; // used for timing how long data stays in the
queue.
+#endif
};
Index: http.h
===================================================================
RCS file: /sources/gnash/gnash/cygnal/http.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- http.h 18 Mar 2008 19:54:55 -0000 1.15
+++ http.h 20 Mar 2008 02:25:57 -0000 1.16
@@ -203,8 +203,8 @@
// These accessors are used mostly just for debugging.
bool keepAlive() { return _keepalive; }
int getFileSize() { return _filesize; }
- std::string getFilespec() { return _filespec; }
- std::string getURL() { return _url; }
+ std::string &getFilespec() { return _filespec; }
+ std::string &getURL() { return _url; }
std::map<int, struct status_codes *> getStatusCodes()
{ return _status_codes; }
std::string getVersion() { return _version; }
Index: buffer.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/buffer.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- buffer.cpp 19 Mar 2008 17:47:08 -0000 1.4
+++ buffer.cpp 20 Mar 2008 02:25:57 -0000 1.5
@@ -39,6 +39,9 @@
empty();
}
+#ifdef USE_STATISTICS
+ clock_gettime (CLOCK_REALTIME, &_stamp);
+#endif
return _ptr;
}
@@ -64,6 +67,13 @@
{
// GNASH_REPORT_FUNCTION;
if (_ptr) {
+#ifdef USE_STATISTICS
+ struct timespec now;
+ clock_gettime (CLOCK_REALTIME, &now);
+ log_debug("Buffer %x (%d) stayed in queue for %g seconds",
+ (void *)_ptr, _nbytes,
+ (float)((now.tv_sec - _stamp.tv_sec) + ((now.tv_nsec -
_stamp.tv_nsec)/1000000.0)));
+#endif
delete[] _ptr;
_ptr = 0;
_nbytes = 0;
Index: cque.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/cque.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- cque.cpp 19 Mar 2008 17:47:08 -0000 1.4
+++ cque.cpp 20 Mar 2008 02:25:57 -0000 1.5
@@ -25,6 +25,7 @@
#include <deque>
#include "log.h"
+#include "gmemory.h"
#include "buffer.h"
#include "cque.h"
@@ -32,6 +33,7 @@
using namespace std;
using namespace boost;
+
namespace cygnal
{
@@ -106,7 +108,7 @@
CQue::pop()
{
// GNASH_REPORT_FUNCTION;
- Buffer *buf;
+ Buffer *buf = 0;
boost::mutex::scoped_lock lock(_mutex);
if (_que.size()) {
buf = _que.front();
Index: cygnal.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/cygnal.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- cygnal.cpp 19 Mar 2008 17:47:08 -0000 1.27
+++ cygnal.cpp 20 Mar 2008 02:25:57 -0000 1.28
@@ -200,7 +200,8 @@
// boost::thread rtmp_port(boost::bind(&rtmp_thread, &rtmp_data));
int retries = 10;
- while (retries-- > 0) {
+ // Run forever
+ while (retries > 0) {
Handler::thread_params_t http_data;
http_data.netfd = 0;
http_data.port = port_offset + 80;
Index: handler.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/handler.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- handler.cpp 19 Mar 2008 17:47:08 -0000 1.5
+++ handler.cpp 20 Mar 2008 02:25:57 -0000 1.6
@@ -43,13 +43,13 @@
Handler::Handler()
: _die(false), _netfd(0)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
}
Handler::~Handler()
{
- GNASH_REPORT_FUNCTION;
- closeNet();
+// GNASH_REPORT_FUNCTION;
+ closeConnection();
_die = true;
notifyout();
notifyin();
@@ -159,6 +159,7 @@
_incoming.setName("Incoming");
_outgoing.setName("Outgoing");
// toggleDebug(true); // FIXME:
+ closeNet();
createServer(args->port);
while (retries-- > 0) {
log_debug(_("%s: Starting Handlers for port %d"), __PRETTY_FUNCTION__,
args->port);
@@ -166,20 +167,16 @@
args->netfd = getFileFd();
args->handle = this;
- log_debug("Starting thread 1");
boost::thread handler(boost::bind(&httphandler, args));
-#if 1
- log_debug("Starting thread 2");
boost::thread outport(boost::bind(&netout_handler, args));
-#endif
- log_debug("Starting thread 3");
boost::thread inport(boost::bind(&netin_handler, args));
inport.join();
-// outport.join();
+ outport.join();
handler.join();
if (_die) {
+ log_debug("Handler done...");
break;
}
}
@@ -202,8 +199,7 @@
Handler *hand = reinterpret_cast<Handler *>(args->handle);
- int retries = 3;
- while (retries-- > 0) {
+ do {
Buffer *buf = new Buffer;
int ret = hand->readNet(buf->reference(), buf->size());
if (ret >= 0) {
@@ -215,11 +211,12 @@
// cerr << str << endl;
hand->notify();
} else {
- log_debug("exiting, no data");
+ log_debug("no more data, exiting...");
hand->die();
break;
}
- }
+ } while (!hand->timetodie());
+ log_debug("Net In handler done...");
hand->notify();
hand->clearall();
// hand->dump();
@@ -241,6 +238,7 @@
delete buf;
}
if (hand->timetodie()) {
+ log_debug("Net Out handler done...");
break;
}
} while (ret >= 0);
Index: http.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/http.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- http.cpp 19 Mar 2008 17:47:08 -0000 1.21
+++ http.cpp 20 Mar 2008 02:25:57 -0000 1.22
@@ -52,7 +52,7 @@
static const int readsize = 1024;
HTTP::HTTP()
- : _filesize(0), _port(80), _keepalive(false), _handler(0)
+ : _filesize(0), _port(80), _keepalive(true), _handler(0)
{
// GNASH_REPORT_FUNCTION;
// struct status_codes *status = new struct status_codes;
@@ -115,6 +115,11 @@
// _handler->wait();
Buffer *buf = _handler->pop();
+ if (buf == 0) {
+ log_debug("Que empty, net connection dropped");
+ return "";
+ }
+
// const char *ptr = reinterpret_cast<const char *>(buf->reference());
// if (readNet(buffer, readsize) > 0) {
// log_debug (_("Read initial GET Request"));
@@ -133,7 +138,7 @@
extractConnection(buf);
extractEncoding(buf);
extractTE(buf);
-// dump();
+ dump();
// // See if we got a legit GET request
// if (strncmp(ptr, "GET ", 4) == 0) {
@@ -162,14 +167,14 @@
// GNASH_REPORT_FUNCTION;
_header << "HTTP/1.1 200 OK" << endl;
- this->formatServer();
- this->formatDate();
- this->formatConnection("close");
+ formatServer();
+ formatDate();
+// this->formatConnection("Keep-alive"); // this is the default for HTTP 1.1
// _header << "Accept-Ranges: bytes" << endl;
- this->formatContentLength(filesize);
- this->formatContentType();
+ formatContentLength(filesize);
+ formatContentType();
// All HTTP messages are followed by a blank line.
- this->terminateHeader();
+ terminateHeader();
return true;
}
@@ -813,6 +818,7 @@
continue;
} else { // not a directory
log_debug("%s is not a directory\n", actual_filespec.c_str());
+ _filespec = actual_filespec;
string::size_type pos;
pos = filespec.rfind(".");
if (pos != string::npos) {
@@ -894,19 +900,27 @@
HTTP www;
www.setHandler(hand);
- hand->wait();
-
-// www.toggleDebug(true);
-
-// log_debug(_("%s: Thread for port %d looping..."), __PRETTY_FUNCTION__,
args->port);
-
string docroot = args->filespec;
+ while (!hand->timetodie()) {
+ log_debug(_("Waiting for GET request..."));
+ hand->wait();
+#ifdef USE_STATISTICS
+ struct timespec start;
+ clock_gettime (CLOCK_REALTIME, &start);
+#endif
+
// conndata->statistics->setFileType(NetStats::RTMPT);
// conndata->statistics->startClock();
// args->netfd = www.getFileFd();
url = docroot;
- url += www.waitForGetRequest();
+ string str = www.waitForGetRequest();
+ if (str.size() == 0) {
+ hand->die();
+// log_debug("Net HTTP done...");
+ return;
+ }
+ url += str;
pos = url.find("?");
filespec = url.substr(0, pos);
parameters = url.substr(pos + 1, url.size());
@@ -926,15 +940,22 @@
// st.setBytes(www.getBytesIn() + www.getBytesOut());
// conndata->statistics->addStats();
+ if (filespec[filespec.size()-1] == '/') {
+ filespec += "/index.html";
+ }
if (url != docroot) {
log_debug (_("File to load is: %s"), filespec.c_str());
log_debug (_("Parameters are: %s"), parameters.c_str());
struct stat st;
int filefd, ret;
+#ifdef USE_STATISTICS
+ struct timespec start;
+ clock_gettime (CLOCK_REALTIME, &start);
+#endif
if (stat(filespec.c_str(), &st) == 0) {
filefd = ::open(filespec.c_str(), O_RDONLY);
log_debug (_("File \"%s\" is %lld bytes in size."), filespec,
- (long long int) st.st_size);
+ st.st_size);
do {
Buffer *buf = new Buffer;
ret = read(filefd, buf->reference(), buf->size());
@@ -942,23 +963,53 @@
delete buf;
break;
}
+ if (ret != buf->size()) {
+ buf->resize(ret);
+ }
// log_debug("Read %d bytes from %s.", ret, filespec);
+#if 0
hand->pushout(buf);
hand->notifyout();
+#else
+ // Don't bother with the outgoing que
+ if (ret > 0) {
+ ret = hand->writeNet(buf);
+ }
+ delete buf;
+#endif
} while(ret > 0);
+ // See if this is a persistant connection
+ if (!www.keepAlive()) {
+ log_debug("Keep-Alive is off", www.keepAlive());
+// hand->closeConnection();
+ }
+#ifdef USE_STATISTICS
+ struct timespec end;
+ clock_gettime (CLOCK_REALTIME, &end);
+ log_debug("Read %d bytes from \"%s\" in %g seconds",
+ st.st_size, filespec,
+ (float)((end.tv_sec - start.tv_sec) + ((end.tv_nsec -
start.tv_nsec)/1000000.0)));
+#endif
}
// memset(args->filespec, 0, 256);
// memcpy(->filespec, filespec.c_str(), filespec.size());
// boost::thread sendthr(boost::bind(&stream_thread, args));
// sendthr.join();
}
- // See if this is a persistant connection
-// if (!www.keepAlive()) {
-// www.closeConnection();
-// }
+#ifdef USE_STATISTICS
+ struct timespec end;
+ clock_gettime (CLOCK_REALTIME, &end);
+ log_debug("Processing time for GET request was %g seconds",
+ (float)((end.tv_sec - start.tv_sec) + ((end.tv_nsec -
start.tv_nsec)/1000000.0)));
+#endif
// conndata->statistics->dump();
// }
-}
+ } // end of while retries
+
+ log_debug("Net HTTP done...");
+
+} // end of httphandler
+
} // end of extern C
} // end of cygnal namespace
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/cygnal/ChangeLog,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- ChangeLog 19 Mar 2008 17:47:08 -0000 1.10
+++ ChangeLog 20 Mar 2008 02:25:57 -0000 1.11
@@ -1,5 +1,16 @@
+
2008-03-19 Rob Savoye <address@hidden>
+ * buffer.{h,cpp}: Add support for optional performance testing
+ statistics
+ * cque.cpp: Set the returned buffer to zero if the mutex has an
+ error.
+ * cygnal.cpp: Rn forever, restarting connections after the
+ disconnect.
+ * handler.cpp: Trap mutex errors.
+ * http.cpp: Tweak the handling of persistant connections. Add
+ statistics gathering.
+
* buffer.cpp, cque.cpp: Turn off overly verbose debug now that
cygnal works again.
* handler.cpp: Rearrange when the Handler gets created. Start the
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash/cygnal buffer.h http.h buffer.cpp cque.cp...,
Rob Savoye <=