gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/rtmp r9712: deal with pollfds so we can ha


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9712: deal with pollfds so we can handle using poll() as a performance hack.
Date: Thu, 06 Nov 2008 15:45:16 -0700
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9712
committer: address@hidden
branch nick: rtmp
timestamp: Thu 2008-11-06 15:45:16 -0700
message:
  deal with pollfds so we can handle using poll() as a performance hack.
modified:
  libnet/handler.cpp
  libnet/handler.h
=== modified file 'libnet/handler.cpp'
--- a/libnet/handler.cpp        2008-11-06 03:12:35 +0000
+++ b/libnet/handler.cpp        2008-11-06 22:45:16 +0000
@@ -189,9 +189,33 @@
 };
 
 void
+Handler::erasePollFD(vector<struct pollfd>::iterator &itt)
+{
+//    GNASH_REPORT_FUNCTION;
+    boost::mutex::scoped_lock lock(_poll_mutex);
+//    struct pollfd fff = _pollfds.at(fd);
+#if 1
+    if (_pollfds.size() <= 1) {
+       _pollfds.clear();
+    } else {
+       _pollfds.erase(itt);
+    }
+#else
+    vector<struct pollfd>::iterator it;
+    for (it=_pollfds.begin(); it<_pollfds.end(); it++) {
+       if ((*it).fd == fd) {
+           _pollfds.erase(it);
+       }
+    }
+#endif
+    
+//    _handlers[fd] = 0;
+}
+
+void
 Handler::addEntry(int fd, Handler::entry_t *func)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     boost::mutex::scoped_lock lock(_poll_mutex);
     _handlers[fd] = func;
 }
@@ -199,7 +223,7 @@
 Handler::entry_t *
 Handler::getEntry(int fd)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     boost::mutex::scoped_lock lock(_poll_mutex);
     return _handlers[fd];
 };
@@ -268,7 +292,7 @@
     struct pollfd *fds;
     int nfds = 1;
     Network net;
-    boost::shared_ptr<vector<int> > hits = net.waitForNetData(nfds, fds);
+    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++) {

=== modified file 'libnet/handler.h'
--- a/libnet/handler.h  2008-11-06 03:12:35 +0000
+++ b/libnet/handler.h  2008-11-06 22:45:16 +0000
@@ -177,11 +177,19 @@
     void die() { _die = true; _outgoing.notify(); };
     bool timetodie() { return _die; };
 
+    // The pollfd are an array of data structures used by the poll()
+    // system call. We have to keep track of these as network
+    // connections get added and disconnected.
     void addPollFD(struct pollfd &fd, entry_t *ptr);
     void addPollFD(struct pollfd &fd);
-    struct pollfd &getPollFD(int index);
+    void erasePollFD(std::vector<struct pollfd>::iterator &itt);
+    struct pollfd &getPollFD(int fd);
     struct pollfd *getPollFDPtr();
+    size_t getPollFDSize() { return _pollfds.size(); };
+    void clearPollFD() { _pollfds.clear(); };
 
+    // The entry point is an function pointer, which is the event
+    // handler when there is data on a file descriptor.
     void addEntry(int fd, entry_t *func);
     entry_t *getEntry(int fd);
     


reply via email to

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