[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/cygnal ChangeLog buffer.cpp cque.cpp cygn...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash/cygnal ChangeLog buffer.cpp cque.cpp cygn... |
Date: |
Wed, 19 Mar 2008 17:47:09 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 08/03/19 17:47:09
Modified files:
cygnal : ChangeLog buffer.cpp cque.cpp cygnal.cpp
handler.cpp handler.h http.cpp
Log message:
* buffer.cpp, cque.cpp: Turn off overly verbose debug now that
cygnal works again.
* handler.cpp: Rearrange when the Handler gets created. Start
the
process thread before the I/O threads to avoid timing problems
if
there is data in the network buffer when starting.
* handler.h: Add a die method for threads so we know when we're
done.
* http.cpp: Turn off overly verbose debug now that cygnal works
again. Read the file specified in the GET request and stick it
in
the output que.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/ChangeLog?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/buffer.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/cque.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/cygnal.cpp?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/handler.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/handler.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.cpp?cvsroot=gnash&r1=1.20&r2=1.21
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/cygnal/ChangeLog,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- ChangeLog 18 Mar 2008 22:04:28 -0000 1.9
+++ ChangeLog 19 Mar 2008 17:47:08 -0000 1.10
@@ -1,3 +1,16 @@
+2008-03-19 Rob Savoye <address@hidden>
+
+ * buffer.cpp, cque.cpp: Turn off overly verbose debug now that
+ cygnal works again.
+ * handler.cpp: Rearrange when the Handler gets created. Start the
+ process thread before the I/O threads to avoid timing problems if
+ there is data in the network buffer when starting.
+ * handler.h: Add a die method for threads so we know when we're
+ done.
+ * http.cpp: Turn off overly verbose debug now that cygnal works
+ again. Read the file specified in the GET request and stick it in
+ the output que.
+
2008-03-18 Rob Savoye <address@hidden>
* buffer.{h,cpp}: Add a few ::copy methods to put data into a
Index: buffer.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/buffer.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- buffer.cpp 18 Mar 2008 22:04:28 -0000 1.3
+++ buffer.cpp 19 Mar 2008 17:47:08 -0000 1.4
@@ -151,7 +151,7 @@
void *
Buffer::resize(size_t nbytes)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
// Allocate a new memory block
Network::byte_t *tmp = new Network::byte_t[nbytes];
// And copy ourselves into it
Index: cque.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/cque.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- cque.cpp 18 Mar 2008 22:04:28 -0000 1.3
+++ cque.cpp 19 Mar 2008 17:47:08 -0000 1.4
@@ -59,25 +59,25 @@
void
CQue::wait()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
boost::mutex::scoped_lock lk(_cond_mutex);
_cond.wait(lk);
- log_debug("wait mutex released for \"%s\"", _name);
+// log_debug("wait mutex released for \"%s\"", _name);
}
// Notify a condition variable to trigger
void
CQue::notify()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
_cond.notify_one();
- log_debug("wait mutex triggered for \"%s\"", _name);
+// log_debug("wait mutex triggered for \"%s\"", _name);
}
size_t
CQue::size()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
boost::mutex::scoped_lock lock(_mutex);
return _que.size();
}
@@ -85,7 +85,7 @@
bool
CQue::push(Buffer *data)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
boost::mutex::scoped_lock lock(_mutex);
_que.push_back(data);
return true;
@@ -95,7 +95,7 @@
bool
CQue::push(gnash::Network::byte_t *data, int nbytes)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
Buffer *buf = new Buffer;
std::copy(data, data + nbytes, buf->reference());
}
@@ -105,7 +105,7 @@
Buffer *
CQue::pop()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
Buffer *buf;
boost::mutex::scoped_lock lock(_mutex);
if (_que.size()) {
@@ -119,7 +119,7 @@
Buffer *
CQue::peek()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
boost::mutex::scoped_lock lock(_mutex);
if (_que.size()) {
return _que.front();
Index: cygnal.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/cygnal.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- cygnal.cpp 19 Mar 2008 12:04:23 -0000 1.26
+++ cygnal.cpp 19 Mar 2008 17:47:08 -0000 1.27
@@ -194,18 +194,22 @@
act.sa_handler = cntrlc_handler;
sigaction (SIGINT, &act, NULL);
- Handler::thread_params_t http_data;
// struct thread_params rtmp_data;
// struct thread_params ssl_data;
// rtmp_data.port = port_offset + 1935;
// boost::thread rtmp_port(boost::bind(&rtmp_thread, &rtmp_data));
- Handler hand;
+ int retries = 10;
+ while (retries-- > 0) {
+ Handler::thread_params_t http_data;
http_data.netfd = 0;
http_data.port = port_offset + 80;
- http_data.handle = &hand;
http_data.filespec = docroot;
- hand.start(&http_data);
+ Handler *hand = new Handler;
+ http_data.handle = &hand;
+ hand->start(&http_data);
+ delete hand;
+ }
// boost::thread http_port(boost::bind(&nethandler, &http_data));
#if 0
Index: handler.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/handler.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- handler.cpp 18 Mar 2008 22:04:28 -0000 1.4
+++ handler.cpp 19 Mar 2008 17:47:08 -0000 1.5
@@ -41,13 +41,18 @@
{
Handler::Handler()
+ : _die(false), _netfd(0)
{
-// GNASH_REPORT_FUNCTION;
+ GNASH_REPORT_FUNCTION;
}
Handler::~Handler()
{
-// GNASH_REPORT_FUNCTION;
+ GNASH_REPORT_FUNCTION;
+ closeNet();
+ _die = true;
+ notifyout();
+ notifyin();
}
bool
@@ -153,7 +158,7 @@
_incoming.setName("Incoming");
_outgoing.setName("Outgoing");
- toggleDebug(true); // FIXME:
+// toggleDebug(true); // FIXME:
createServer(args->port);
while (retries-- > 0) {
log_debug(_("%s: Starting Handlers for port %d"), __PRETTY_FUNCTION__,
args->port);
@@ -162,7 +167,7 @@
args->handle = this;
log_debug("Starting thread 1");
- boost::thread inport(boost::bind(&netin_handler, args));
+ boost::thread handler(boost::bind(&httphandler, args));
#if 1
log_debug("Starting thread 2");
@@ -170,11 +175,13 @@
#endif
log_debug("Starting thread 3");
- boost::thread handler(boost::bind(&httphandler, args));
-
+ boost::thread inport(boost::bind(&netin_handler, args));
inport.join();
// outport.join();
handler.join();
+ if (_die) {
+ break;
+ }
}
}
@@ -199,7 +206,7 @@
while (retries-- > 0) {
Buffer *buf = new Buffer;
int ret = hand->readNet(buf->reference(), buf->size());
- if (ret > 0) {
+ if (ret >= 0) {
if (ret != buf->size()) {
buf->resize(ret);
}
@@ -208,11 +215,13 @@
// cerr << str << endl;
hand->notify();
} else {
- cerr << __PRETTY_FUNCTION__ << "exiting, no data" << endl;
+ log_debug("exiting, no data");
+ hand->die();
break;
}
}
hand->notify();
+ hand->clearall();
// hand->dump();
}
void
@@ -221,15 +230,20 @@
GNASH_REPORT_FUNCTION;
int retries = 10;
int ret;
-
- do {
Handler *hand = reinterpret_cast<Handler *>(args->handle);
+ do {
hand->waitout();
+ while (hand->outsize()) {
Buffer *buf = hand->popout();
- buf->dump();
+// log_debug("FIXME: got data in Outgoing que");
+// buf->dump();
ret = hand->writeNet(buf);
- } while (ret > 0);
-
+ delete buf;
+ }
+ if (hand->timetodie()) {
+ break;
+ }
+ } while (ret >= 0);
}
} // end of extern C
Index: handler.h
===================================================================
RCS file: /sources/gnash/gnash/cygnal/handler.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- handler.h 18 Mar 2008 01:06:04 -0000 1.3
+++ handler.h 19 Mar 2008 17:47:08 -0000 1.4
@@ -123,7 +123,12 @@
// Dump internal data.
void dump();
+
+ void die() { _die = true; _outgoing.notify(); };
+ bool timetodie() { return _die; };
+
private:
+ bool _die;
int _netfd;
CQue _incoming;
CQue _outgoing;
Index: http.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/http.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- http.cpp 18 Mar 2008 22:04:28 -0000 1.20
+++ http.cpp 19 Mar 2008 17:47:08 -0000 1.21
@@ -26,6 +26,9 @@
//#include <boost/date_time/local_time/local_time.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
//#include <boost/date_time/time_zone_base.hpp>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <string>
#include <iostream>
#include <cstring>
@@ -146,7 +149,7 @@
bool
HTTP::formatHeader(const short type)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
formatHeader(_filesize, type);
return true;
@@ -156,7 +159,7 @@
bool
HTTP::formatHeader(int filesize, const short type)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
_header << "HTTP/1.1 200 OK" << endl;
this->formatServer();
@@ -173,7 +176,7 @@
bool
HTTP::formatErrorResponse(http_status_e code)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
// First build the message body, so we know how to set Content-Length
_body << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">" << endl;
@@ -201,7 +204,7 @@
bool
HTTP::formatDate()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
boost::posix_time::ptime now =
boost::posix_time::second_clock::local_time();
// cout << now.time_of_day() << endl;
@@ -230,7 +233,7 @@
bool
HTTP::formatServer()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
_header << "Server: Cygnal (GNU/Linux)" << endl;
return true;
}
@@ -238,7 +241,7 @@
bool
HTTP::formatServer(const string &data)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
_header << "Server: " << data << endl;
return true;
}
@@ -246,7 +249,7 @@
bool
HTTP::formatMethod(const string &data)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
_header << "Method: " << data << endl;
return true;
}
@@ -254,7 +257,7 @@
bool
HTTP::formatReferer(const string &refer)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
_header << "Referer: " << refer << endl;
return true;
}
@@ -262,7 +265,7 @@
bool
HTTP::formatConnection(const string &options)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
_header << "Connection: " << options << endl;
return true;
}
@@ -343,7 +346,7 @@
bool
HTTP::formatCharset(const string &set)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
// For some browsers this appears to also be Content-Charset
_header << "Accept-Charset: " << set << endl;
return true;
@@ -352,7 +355,7 @@
bool
HTTP::formatEncoding(const string &code)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
_header << "Accept-Encoding: " << code << endl;
return true;
}
@@ -360,7 +363,7 @@
bool
HTTP::formatTE(const string &te)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
_header << "TE: " << te << endl;
return true;
}
@@ -375,7 +378,7 @@
Buffer *buf = new Buffer;
// Network::byte_t *ptr = (Network::byte_t *)_body.str().c_str();
// buf->copy(ptr, _body.str().size());
- _handler->dump();
+// _handler->dump();
if (_header.str().size()) {
buf->resize(_header.str().size());
string str = _header.str();
@@ -395,7 +398,7 @@
bool
HTTP::formatRequest(const string &url, http_method_e req)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
_header.str("");
@@ -895,10 +898,7 @@
// www.toggleDebug(true);
-// www.createServer(args->port);
-// while (retries-- > 0) {
// log_debug(_("%s: Thread for port %d looping..."), __PRETTY_FUNCTION__,
args->port);
-// www.newConnection(true);
string docroot = args->filespec;
@@ -927,8 +927,26 @@
// conndata->statistics->addStats();
if (url != docroot) {
-// log_debug (_("File to load is: %s"), filespec.c_str());
-// log_debug (_("Parameters are: %s"), parameters.c_str());
+ log_debug (_("File to load is: %s"), filespec.c_str());
+ log_debug (_("Parameters are: %s"), parameters.c_str());
+ struct stat st;
+ int filefd, ret;
+ 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);
+ do {
+ Buffer *buf = new Buffer;
+ ret = read(filefd, buf->reference(), buf->size());
+ if (ret == 0) { // the file is done
+ delete buf;
+ break;
+ }
+// log_debug("Read %d bytes from %s.", ret, filespec);
+ hand->pushout(buf);
+ hand->notifyout();
+ } while(ret > 0);
+ }
// memset(args->filespec, 0, 256);
// memcpy(->filespec, filespec.c_str(), filespec.size());
// boost::thread sendthr(boost::bind(&stream_thread, args));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash/cygnal ChangeLog buffer.cpp cque.cpp cygn...,
Rob Savoye <=