Ok, I fixed the bug. It was very obscure as the library had not built a mechanism for going from multi destination to single destination, so it would never reset the default peer to the only destination. Fix is included in the new version of my std::list patch


On Thu, 3 Mar 2005, Dan Weber wrote:


Ok, so I patched in my std::list implementation and it works great for the most part. Apparently it doesn't fix this problem... I've verified I've removed it from the list, however, I do not understand why it continues to send rtp to a place I have removed.


Dan


_______________________________________________ Ccrtp-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/ccrtp-devel
Index: ccrtp/src/ccrtp/oqueue.h
===================================================================
--- ccrtp.orig/src/ccrtp/oqueue.h       2005-02-06 18:12:52.000000000 -0500
+++ ccrtp/src/ccrtp/oqueue.h    2005-03-03 18:17:16.395525536 -0500
@@ -45,6 +45,7 @@
 #define CCXX_RTP_OQUEUE_H_
 
 #include <ccrtp/queuebase.h>
+#include <list>
 
 #ifdef CCXX_NAMESPACES
 namespace ost {
@@ -80,7 +81,12 @@
        { return (destinationCounter == 1); }
 
        inline TransportAddress* getFirstDestination() const
-       { return firstDestination; }
+       { 
+               if (destinationCounter > 0)
+                       return destList.front();
+               else
+                       return NULL;
+       }
 
        inline void lockDestinationList() const
        { destinationLock.readLock(); }
@@ -110,15 +116,9 @@
        { 
                TransportAddress(InetAddress na, tpport_t dtp, tpport_t ctp) :
                        networkAddress(na), dataTransportPort(dtp), 
-                       controlTransportPort(ctp), next(NULL)
+                       controlTransportPort(ctp)
                {  }
 
-               inline TransportAddress* getNext()
-               { return next; }
-
-               inline void setNext(TransportAddress* nc)
-               { next = nc; }
-
                inline const InetAddress& getNetworkAddress() const
                { return networkAddress; }
 
@@ -130,12 +130,12 @@
 
                InetAddress networkAddress;
                tpport_t dataTransportPort, controlTransportPort;
-               TransportAddress* next;
        };
 
+        std::list<TransportAddress*> destList;
+
 private:
        uint8 destinationCounter;
-       TransportAddress* firstDestination, * lastDestination;
        mutable ThreadLock destinationLock;
 };
 
Index: ccrtp/src/outqueue.cpp
===================================================================
--- ccrtp.orig/src/outqueue.cpp 2005-03-03 17:11:44.522261128 -0500
+++ ccrtp/src/outqueue.cpp      2005-03-03 21:03:38.219057704 -0500
@@ -37,6 +37,7 @@
 
 #include "private.h"
 #include <ccrtp/oqueue.h>
+#include <iostream>
 
 #ifdef  CCXX_NAMESPACES
 namespace ost {
@@ -52,7 +53,6 @@
 
 DestinationListHandler::DestinationListHandler() :
        destinationCounter(0), 
-       firstDestination(NULL), lastDestination(NULL),
        destinationLock()
 {
 }
@@ -61,9 +61,8 @@
 {
        TransportAddress* tmp;
        writeLockDestinationList();
-       while ( firstDestination ) {
-               tmp = getFirstDestination();
-               firstDestination = firstDestination->getNext();
+       for (std::list<TransportAddress*>::iterator i = destList.begin(); i != 
destList.end(); i++) {
+               tmp = *i;
 #ifdef CCXX_EXCEPTIONS
                try {
 #endif
@@ -81,12 +80,7 @@
 {      
        TransportAddress* addr = new TransportAddress(ia,data,control);
        writeLockDestinationList();
-       if ( firstDestination == NULL )
-               firstDestination = lastDestination = addr;
-       else {
-               lastDestination->setNext(addr);
-               lastDestination = addr;
-       }
+       destList.push_back(addr);
        destinationCounter++;
        unlockDestinationList();
        return true;
@@ -98,27 +92,20 @@
                                                  tpport_t controlPort)
 {
        bool result = false;
-       TransportAddress* prev = NULL;
        writeLockDestinationList();
-       TransportAddress* ta = getFirstDestination();
-       while ( NULL != ta ) {
-               if ( ia == ta->getNetworkAddress() &&
-                    dataPort == ta->getDataTransportPort() &&
-                    controlPort == ta->getControlTransportPort() ) {
+       TransportAddress* tmp;
+       for (std::list<TransportAddress*>::iterator i = destList.begin(); i != 
destList.end() && !result; i++) {
+               tmp = *i;
+               if ( ia == tmp->getNetworkAddress() &&
+                    dataPort == tmp->getDataTransportPort() &&
+                    controlPort == tmp->getControlTransportPort() ) {
                        // matches. -> remove it.
+                       std::cerr << "Removing List Item" << std::endl;
                        result = true;
-                       if ( prev )
-                               prev->setNext(ta->getNext());
-                       else // ( getFirstDestination() == ta ) 
-                               firstDestination = firstDestination->getNext();
-                       if ( lastDestination == ta )
-                               lastDestination = prev;
+                       destList.erase(i);
                        destinationCounter--;
-                       delete ta;
-                       ta = NULL;
-               } else {
-                       prev = ta;
-                       ta = ta->getNext();
+                       
+                       delete tmp;
                }
        }
        unlockDestinationList();
@@ -394,17 +381,23 @@
        uint32 rtn = packet->getPayloadSize();
        lockDestinationList();
        if ( isSingleDestination() ) {
+               TransportAddress* tmp = destList.front();
+               // if going from multi destinations to single destinations
+               setDataPeer(tmp->getNetworkAddress(),
+                           tmp->getDataTransportPort());
+               
                sendData(packet->getRawPacket(),
                         packet->getRawPacketSize());
        } else {
                // when no destination has been added, NULL == dest.
-               TransportAddress* dest = getFirstDestination();
-               while ( dest ) {
+               for (std::list<TransportAddress*>::iterator i = 
destList.begin();
+                    i != destList.end(); i++)
+               {
+                       TransportAddress* dest = *i; 
                        setDataPeer(dest->getNetworkAddress(),
                                    dest->getDataTransportPort());
                        sendData(packet->getRawPacket(),
                                 packet->getRawPacketSize());
-                       dest = dest->getNext();
                }
        }
        unlockDestinationList();
Index: ccrtp/src/control.cpp
===================================================================
--- ccrtp.orig/src/control.cpp  2005-02-10 04:06:00.000000000 -0500
+++ ccrtp/src/control.cpp       2005-03-03 18:22:12.374529888 -0500
@@ -1083,12 +1083,12 @@
                count = sendControl(buffer,len);
        } else {
                // when no destination has been added, NULL == dest.
-               TransportAddress* dest = getFirstDestination();
-               while ( dest ) {
+               for(std::list<TransportAddress*>::iterator i = destList.begin();
+                   i != destList.end(); i++) {
+                       TransportAddress* dest = *i;
                        setControlPeer(dest->getNetworkAddress(),
                                       dest->getControlTransportPort());
                        count += sendControl(buffer,len);
-                       dest = dest->getNext();
                }
        }
        unlockDestinationList();
_______________________________________________
Ccrtp-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/ccrtp-devel

Reply via email to