[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11393: moved before heavy refactori
From: |
Rob Savoye |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11393: moved before heavy refactoring. |
Date: |
Tue, 25 Aug 2009 18:29:07 -0000 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11393
committer: Rob Savoye <address@hidden>
branch nick: trunk
timestamp: Sat 2009-08-08 10:06:45 -0600
message:
moved before heavy refactoring.
removed:
libnet/handler.cpp
libnet/handler.h
added:
cygnal/handler.cpp
cygnal/handler.h
=== added file 'cygnal/handler.cpp'
--- a/cygnal/handler.cpp 1970-01-01 00:00:00 +0000
+++ b/cygnal/handler.cpp 2009-08-08 16:06:45 +0000
@@ -0,0 +1,84 @@
+//
+// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <string>
+#include <deque>
+#include <list>
+#include <map>
+#include <vector>
+
+#include "log.h"
+#include "network.h"
+#include "buffer.h"
+#include "utility.h"
+#include "dsodefs.h" //For DSOEXPORT.
+#include "handler.h"
+
+#include "rtmp.h"
+#include "http.h"
+
+using namespace gnash;
+using namespace std;
+using namespace boost;
+
+namespace cygnal
+{
+
+map<int, Handler *> DSOEXPORT handlers;
+
+Handler::Handler()
+ : _in_fd(0)
+{
+// GNASH_REPORT_FUNCTION;
+}
+
+Handler::~Handler()
+{
+// GNASH_REPORT_FUNCTION;
+}
+
+bool
+Handler::sync(int in_fd)
+{
+// GNASH_REPORT_FUNCTION;
+
+}
+
+// Dump internal data.
+void
+Handler::dump()
+{
+// GNASH_REPORT_FUNCTION;
+}
+
+} // end of gnash namespace
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
+
=== added file 'cygnal/handler.h'
--- a/cygnal/handler.h 1970-01-01 00:00:00 +0000
+++ b/cygnal/handler.h 2009-08-08 16:06:45 +0000
@@ -0,0 +1,120 @@
+//
+// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifndef __HANDLER_H__
+#define __HANDLER_H__ 1
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#include <boost/cstdint.hpp>
+#include <boost/thread/mutex.hpp>
+//#include <boost/thread/condition.hpp>
+#include <string>
+#include <deque>
+#include <map>
+
+#ifdef HAVE_POLL
+# include <sys/poll.h>
+#else
+# ifdef HAVE_EPOLL
+# include <sys/epoll.h>
+# endif
+#endif
+
+#include "log.h"
+#include "network.h"
+#include "buffer.h"
+#include "element.h"
+#include "cque.h"
+#include "network.h"
+#include "dsodefs.h" //For DSOEXPORT.
+#include "proc.h"
+
+#include "diskstream.h"
+#include "sharedlib.h"
+
+// _definst_ is the default instance name
+namespace cygnal
+{
+
+class Handler
+{
+public:
+ /// \enum admin_cmd_e
+ /// The Admin command sent by the client
+ typedef enum {
+ UNKNOWN,
+ STATUS,
+ POLL,
+ HELP,
+ INTERVAL,
+ QUIT,
+ } admin_cmd_e;
+
+ DSOEXPORT Handler();
+ ~Handler();
+
+ /// \var sync
+ /// Send the onSync message to all connectec cients
+ bool sync() { return sync(_in_fd); };
+ bool sync(int in_fd);
+
+// Dump internal data.
+ void dump();
+
+ size_t addFile(int x) { _clients.push_back(x); };
+
+protected:
+ /// Each incoming request has one of 4 states the server has to
handle
+ /// to send a response.
+
+ /// \var _clients
+ /// is the array of all clients connected to this server for this
+ /// application. This is where all the output goes.
+ std::vector<int> _clients;
+ /// \var _remote
+ /// connections are network connections to other processes,
+ /// possibly on another computer.
+ boost::shared_ptr<cygnal::Proc> _remote;
+ /// \var _plugins
+ /// is for the dynamically loaded applications
+ boost::shared_ptr<gnash::SharedLib> _plugin;
+ /// \var _file
+ /// is for disk based files
+ std::vector<boost::shared_ptr<gnash::DiskStream> > _file;
+ /// \var _sol
+ /// is for remote SharedObjects
+ std::vector<boost::shared_ptr<amf::Element> > _sol;
+ /// \var _in_fd
+ /// The file descriptor of the incoming data
+ int _in_fd;
+
+// Remote Shared Objects. References are an index into this vector.
+// std::map<std::string, boost::shared_ptr<handler_t> > _handlers;
+};
+
+} // end of gnash namespace
+
+#endif // end of __HANDLER_H__
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
=== removed file 'libnet/handler.cpp'
--- a/libnet/handler.cpp 2009-08-04 17:39:22 +0000
+++ b/libnet/handler.cpp 1970-01-01 00:00:00 +0000
@@ -1,369 +0,0 @@
-//
-// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
-#include <boost/thread/thread.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/bind.hpp>
-#include <algorithm>
-#include <string>
-#include <deque>
-#include <list>
-#include <map>
-#include <vector>
-
-#include "log.h"
-#include "network.h"
-#include "buffer.h"
-#include "utility.h"
-#include "dsodefs.h" //For DSOEXPORT.
-
-#include "rtmp.h"
-#include "http.h"
-
-using namespace gnash;
-using namespace std;
-using namespace boost;
-
-namespace gnash
-{
-
-map<int, Handler *> DSOEXPORT handlers;
-
-Handler::Handler()
- : _die(false), _netfd(0)
-{
-// GNASH_REPORT_FUNCTION;
-}
-
-Handler::~Handler()
-{
-// GNASH_REPORT_FUNCTION;
-// closeConnection();
- _die = true;
-// notifyout();
- notifyin();
-}
-
-bool
-Handler::push(boost::shared_ptr<amf::Buffer> data, fifo_e direction)
-{
-// GNASH_REPORT_FUNCTION;
-#if 0
- if (direction == Handler::OUTGOING) {
- _outgoing.push(data);
- return true;
- }
-#endif
- if (direction == Handler::INCOMING) {
- _incoming.push(data);
- return true;
- }
-
- return false;
-}
-
-// Push bytes on the outgoing FIFO
-bool
-Handler::push(boost::uint8_t *data, int nbytes, fifo_e direction)
-{
-// GNASH_REPORT_FUNCTION;
- boost::shared_ptr<amf::Buffer> ptr(new amf::Buffer);
- ptr->copy(data, nbytes);
- return push(ptr, direction);
-}
-
-// Pop the first date element off the FIFO
-boost::shared_ptr<amf::Buffer>
-Handler::pop(fifo_e direction)
-{
-// GNASH_REPORT_FUNCTION;
- boost::shared_ptr<amf::Buffer> buf;
-
-#if 0
- if (direction == Handler::OUTGOING) {
- if (_outgoing.size()) {
- buf = _outgoing.pop();
- return buf;
- }
- }
-#endif
- if (direction == Handler::INCOMING) {
- if (_incoming.size()) {
- buf = _incoming.pop();
- return buf;
- }
- }
-
- return buf;
-}
-
-// Peek at the first data element without removing it
-boost::shared_ptr<amf::Buffer>
-Handler::peek(fifo_e direction)
-{
-// GNASH_REPORT_FUNCTION;
-#if 0
- if (direction == Handler::OUTGOING) {
- if (_outgoing.size()) {
- return _outgoing.peek();
- }
- }
-#endif
- if (direction == Handler::INCOMING) {
- if (_incoming.size()) {
- return _incoming.peek();
- }
- }
- return boost::shared_ptr<amf::Buffer>();
-}
-
-// Return the size of the queues
-size_t
-Handler::size(fifo_e direction)
-{
-// GNASH_REPORT_FUNCTION;
-#if 0
- if (direction == Handler::OUTGOING) {
- return _outgoing.size();
- }
-#endif
- if (direction == Handler::INCOMING) {
- return _incoming.size();
- }
-
- return 0; // we should never actually get to here
-}
-
-// Return the size of the queues
-void
-Handler::clear(fifo_e direction)
-{
-// GNASH_REPORT_FUNCTION;
-#if 0
- if (direction == Handler::OUTGOING) {
- _outgoing.clear();
- }
-#endif
- if (direction == Handler::INCOMING) {
- _incoming.clear();
- }
-}
-
-// Dump internal data.
-void
-Handler::dump()
-{
-// GNASH_REPORT_FUNCTION;
- _incoming.dump();
-// _outgoing.dump();
-}
-
-#if 0
-size_t
-Handler::readPacket(int fd)
-{
- GNASH_REPORT_FUNCTION;
- boost::shared_ptr<amf::Buffer> buf(new amf::Buffer);
- if (fd <= 2) {
- log_error("File discriptor out of range, %d", fd);
- return -1;
- }
-
- log_debug(_("Waiting for data on fd #%d..."), fd);
- size_t ret = readNet(fd, buf->reference(), buf->size(), 1);
- // the read timed out as there was no data, but the socket is still open.
- if (ret == 0) {
- log_debug("no data yet for fd #%d, continuing...", fd);
- return 0;
- }
- // ret is "no position" when the socket is closed from the other end of
the connection,
- // so we're done.
- if ((ret == string::npos) || (ret == 0xffffffff)) {
- log_debug("socket for fd #%d was closed...", fd);
- return -1;
- }
- // We got data. Resize the buffer if necessary.
- if (ret > 0) {
- if (ret < NETBUFSIZE) {
- buf->resize(ret);
- _incoming.push(buf);
- }
- } else {
- log_debug("no more data for fd #%d, exiting...", fd);
- die();
- return -1;
- }
- return ret;
-}
-#endif
-
-// start the two thread handlers for the queues
-bool
-Handler::start(Network::thread_params_t *args)
-{
- GNASH_REPORT_FUNCTION;
-// Handler *hand = reinterpret_cast<Handler *>(args->handle);
-
- _incoming.setName("Incoming");
-// _outgoing.setName("Outgoing");
-
- log_debug(_("Starting Handlers for port %d, tid %ld"),
- args->port, get_thread_id());
-
- struct pollfd fds; // FIXME: never initialized ?
- int nfds = 1;
- Network net;
- boost::shared_ptr<vector<struct pollfd> > hits = net.waitForNetData(nfds,
&fds);
- vector<int>::const_iterator it;
-#if 0
- for (it = _pollfds.begin(); it != _pollfds.end(); it++) {
-// Buffer buf;
-// net.readNet(*it, buf.reference(), buf.size());
- args->netfd = *it;
- if (crcfile.getThreadingFlag()) {
- if (args->port == port_offset + gnash::RTMPT_PORT) {
- boost::thread handler(boost::bind(&http_handler, args));
- }
- } else {
- callback[*it](args);
- }
- }
-#endif
-
-// boost::thread outport(boost::bind(&netout_handler, args));
-// boost::thread inport(boost::bind(&netin_handler, args));
-
-#if 0
- if (args->port == 4080) { // FIXME: hack alert!
- boost::thread handler(boost::bind(&http_handler, args));
- }
- if (args->port == RTMP_PORT) {
- boost::thread handler(boost::bind(&rtmp_handler, args));
- }
-#endif
-
- return true;
-}
-
-extern "C" {
-void
-netin_handler(Network::thread_params_t *args)
-{
- GNASH_REPORT_FUNCTION;
-
- //Network *net = reinterpret_cast<Network *>(args->handler);
- size_t ret=0;
-
- log_debug("Starting to wait for data in net for fd #%d", args->netfd);
-
- do {
- boost::shared_ptr<amf::Buffer> buf(new amf::Buffer);
-// ret = hand->readNet(args->netfd, buf->reference(), buf->size(), 1);
-
-// cerr << (char *)buf->reference() << endl;
- // the read timed out as there was no data, but the socket is still
open.
- if (ret == 0) {
- log_debug("no data yet for fd #%d, continuing...", args->netfd);
- continue;
- }
- // ret is "no position" when the socket is closed from the other end of
the connection,
- // so we're done.
- if ((ret == string::npos) || (ret == 0xffffffff)) {
- log_debug("socket for fd #%d was closed...", args->netfd);
- break;
- }
- // We got data. Resize the buffer if necessary.
- if (ret > 0) {
-// cerr << "XXXXX" << (char *)buf->reference() << endl;
-// if (ret < NETBUFSIZE) {
-// buf->resize(ret);
-// }
-// hand->push(buf);
-// hand->notify();
- } else {
- log_debug("no more data for fd #%d, exiting...", args->netfd);
-// hand->die();
- break;
- }
-// } while (!hand->timetodie());
- } while (ret > 0);
- // We're done. Notify the other threads the socket is closed, and tell
them to die.
- log_debug("Net In handler done for fd #%d...", args->netfd);
-// hand->notify();
-// hand->closeNet(args->netfd);
-// hand->dump();
-}
-
-#if 0
-void
-netout_handler(Network::thread_params_t *args)
-{
-// GNASH_REPORT_FUNCTION;
- int ret = 0;
- Handler *hand = reinterpret_cast<Handler *>(args->handle);
-
- log_debug("Starting to wait for data in que for fd #%d", args->netfd);
-
- do {
- // Don't look for any more packets in the que cause we're done
- if (hand->timetodie()) {
- break;
- }
- hand->waitout();
- while (hand->outsize()) {
- boost::shared_ptr<amf::Buffer> buf = hand->popout();
-// log_debug("FIXME: got data in Outgoing que");
-// buf->dump();
-// ret = hand->writeNet(buf->reference(), buf->size(), 15);
-// if (buf->size() != gnash::NETBUFSIZE) {
-// log_debug("Got smaller packet, size %d", buf->size());
-// }
- ret = hand->writeNet(args->netfd, buf);
- }
- } while (ret > 0);
- hand->die();
- log_debug("Net Out handler done for fd #%d...", args->netfd);
- hand->notifyin();
- hand->closeNet(args->netfd);
-#if 0
- map<int, Handler *>::iterator hit = handlers.find(args->netfd);
- if ((*hit).second) {
- log_debug("Removing handle %x for fd #%d: ",
- (void *)hand), args->netfd;
- handlers.erase(args->netfd);
- }
- delete hand;
-#endif
-}
-#endif
-
-} // end of extern C
-
-} // end of gnash namespace
-
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
-
=== removed file 'libnet/handler.h'
--- a/libnet/handler.h 2009-08-04 17:39:22 +0000
+++ b/libnet/handler.h 1970-01-01 00:00:00 +0000
@@ -1,198 +0,0 @@
-//
-// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-#ifndef __HANDLER_H__
-#define __HANDLER_H__ 1
-
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
-#include <boost/cstdint.hpp>
-#include <boost/thread/mutex.hpp>
-//#include <boost/thread/condition.hpp>
-#include <string>
-#include <deque>
-#include <map>
-
-#ifdef HAVE_POLL
-# include <sys/poll.h>
-#else
-# ifdef HAVE_EPOLL
-# include <sys/epoll.h>
-# endif
-#endif
-
-#include "log.h"
-#include "network.h"
-#include "buffer.h"
-#include "cque.h"
-#include "network.h"
-#include "dsodefs.h" //For DSOEXPORT.
-
-// _definst_ is the default instance name
-namespace gnash
-{
-
-
-class Handler
-{
-public:
-
- DSOEXPORT Handler();
- ~Handler();
-
- typedef enum {
- UNKNOWN,
- STATUS,
- POLL,
- HELP,
- INTERVAL,
- QUIT,
- } admin_cmd_e;
-
- // Specify which queue should be used
- typedef enum { INCOMING, OUTGOING } fifo_e;
-
- // Push bytes on the incoming FIFO, which is the default
- bool push(boost::shared_ptr<amf::Buffer> data)
- { return _incoming.push(data); };
- bool push(boost::shared_ptr<amf::Buffer> data, fifo_e direction);
- bool push(boost::uint8_t *data, int nbytes, fifo_e direction);
- bool push(boost::uint8_t *data, int nbytes)
- { return _incoming.push(data, nbytes); };
- bool pushin(boost::uint8_t *data, int nbytes)
- { return _incoming.push(data, nbytes); };
- bool pushin(boost::shared_ptr<amf::Buffer> data)
- { return _incoming.push(data); };
-#if 0
- // Push bytes on the incoming FIFO, which must be specified
- bool pushout(boost::uint8_t *data, int nbytes)
- { return _outgoing.push(data, nbytes); };
- bool pushout(boost::shared_ptr<amf::Buffer> data)
- { return _outgoing.push(data); };
-#endif
-
- // Pop the first date element off the incoming FIFO
- boost::shared_ptr<amf::Buffer> pop() { return _incoming.pop(); };
- boost::shared_ptr<amf::Buffer> pop(fifo_e direction);
- boost::shared_ptr<amf::Buffer> popin()
- { return _incoming.pop(); };
-#if 0
- // Pop the first date element off the outgoing FIFO
- boost::shared_ptr<amf::Buffer> popout()
- { return _outgoing.pop(); };
-#endif
- // Peek at the first data element without removing it
- boost::shared_ptr<amf::Buffer> peek() { return _incoming.peek(); };
- boost::shared_ptr<amf::Buffer> peek(fifo_e direction);
- boost::shared_ptr<amf::Buffer> peekin()
- { return _incoming.peek(); };
- // Pop the first date element off the outgoing FIFO
-// boost::shared_ptr<amf::Buffer> peekout() { return _outgoing.peek(); };
-
- // Removes all the buffers from the queues
- boost::shared_ptr<amf::Buffer> merge(boost::shared_ptr<amf::Buffer> begin)
{ return _incoming.merge(begin); };
- boost::shared_ptr<amf::Buffer> mergein(boost::shared_ptr<amf::Buffer>
begin) { return _incoming.merge(begin); };
-// boost::shared_ptr<amf::Buffer> mergeout(boost::shared_ptr<amf::Buffer>
begin) { return _outgoing.merge(begin); };
-
- // Removes all the buffers from the queues
- void clear() { _incoming.clear(); };
- void clear(fifo_e direction);
- void clearin() { _incoming.clear(); };
-#if 0
- void clearout() { _outgoing.clear(); };
- void clearall() { _outgoing.clear(); _incoming.clear(); };
-#endif
- // Return the size of the queues, default to the incoming queue
- size_t size(fifo_e direction);
- size_t size() { return _incoming.size(); };
- size_t insize() { return _incoming.size(); };
-// size_t outsize() { return _outgoing.size(); };
-
- // Notify the other thread a message is in the que
- void notify() { _incoming.notify(); };
- void notifyin() { _incoming.notify(); };
- // void notifyout() { _outgoing.notify(); };
-
- // Wait for a message from the other thread
- void wait() { _incoming.wait(); };
- void waitin() { _incoming.wait(); };
-// void waitout() { _outgoing.wait(); };
-
-// size_t readPacket(int fd);
-
- // start the two thread handlers for the queues
- bool DSOEXPORT start(Network::thread_params_t *args);
-
-#if 0
- /// \brief Write a Buffer the network connection.
- ///
- /// @param fd The file descriptor to write the data too.
- ///
- /// @param buf A smart pointer to a Buffer class.
- ///
- /// @return The number of bytes sent
- int DSOEXPORT writeNet(int fd, boost::shared_ptr<amf::Buffer> &buf)
- { return Network::writeNet(fd, buf->reference(), buf->size()); };
-
- /// \brief Write a Buffer the network connection.
- ///
- /// @param buf A smart pointer to a Buffer class.
- ///
- /// @return The number of bytes sent
- int DSOEXPORT writeNet(boost::shared_ptr<amf::Buffer> &buf)
- { return Network::writeNet(buf->reference(), buf->size()); };
-#endif
-
- // Dump internal data.
- void dump();
-
-#ifdef USE_STATS_QUEUE
- CQue::que_stats_t *statsin() { return _incoming.stats(); };
- CQue::que_stats_t *statsout() { return _outgoing.stats(); };
-#endif
- void die() { _die = true; };
-// void die() { _die = true; _outgoing.notify(); };
- void resetDie() { _die = false; };
- bool timetodie() { return _die; };
-
-private:
- bool _die;
- int _netfd;
- CQue _incoming;
- std::map<int, CQue> _outgoing;
-};
-
-// This is the thread for all incoming network connections, which
-// has to be in C.
-extern "C" {
- void netin_handler(Network::thread_params_t *args);
- void netout_handler(Network::thread_params_t *args);
- void start_handler(Network::thread_params_t *args);
-}
-
-} // end of gnash namespace
-
-#endif // end of __HANDLER_H__
-
-// local Variables:
-// mode: C++
-// tab-width: 8
-// indent-tabs-mode: t
-// End:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11393: moved before heavy refactoring.,
Rob Savoye <=