Revision: 40634
http://brlcad.svn.sourceforge.net/brlcad/?rev=40634&view=rev
Author: davidloman
Date: 2010-09-21 16:28:25 +0000 (Tue, 21 Sep 2010)
Log Message:
-----------
Hash out more of PortalManager::_runLoopPass(). Since the Portal Manager will
be tracking portals in a list, add some mutexing to list access.
Modified Paths:
--------------
rt^3/trunk/include/PortalManager.h
rt^3/trunk/src/libNet/PortalManager.cxx
Modified: rt^3/trunk/include/PortalManager.h
===================================================================
--- rt^3/trunk/include/PortalManager.h 2010-09-21 16:26:24 UTC (rev 40633)
+++ rt^3/trunk/include/PortalManager.h 2010-09-21 16:28:25 UTC (rev 40634)
@@ -27,11 +27,14 @@
#define __PORTALMANAGER_H__
#include "libutility.h"
-
-#include <Qt>
#include "ControlledThread.h"
#include "PkgTcpServer.h"
+#include <Qt>
+#include <QtCore/QList>
+#include <QtCore/QMutex>
+class Portal;
+
class PortalManager : public ControlledThread
{
public:
@@ -45,6 +48,9 @@
private:
quint32 port;
PkgTcpServer* tcpServer;
+
+ QMutex* portalsLock;
+ QList<Portal*>* portals;
};
#endif
Modified: rt^3/trunk/src/libNet/PortalManager.cxx
===================================================================
--- rt^3/trunk/src/libNet/PortalManager.cxx 2010-09-21 16:26:24 UTC (rev
40633)
+++ rt^3/trunk/src/libNet/PortalManager.cxx 2010-09-21 16:28:25 UTC (rev
40634)
@@ -23,6 +23,7 @@
*
*/
+#include "Portal.h"
#include "PortalManager.h"
#include "NetMsgFactory.h"
#include "PkgTcpClient.h"
@@ -30,10 +31,9 @@
PortalManager::PortalManager(quint32 port) : ControlledThread("PortalManager")
{
this->port = port;
-
-
this->tcpServer = new PkgTcpServer();
-
+ this->portals = new QList<Portal*>();
+ this->portalsLock = new QMutex();
}
PortalManager::~PortalManager()
@@ -55,6 +55,33 @@
{
PkgTcpClient* client = (PkgTcpClient*) this->tcpServer->waitForClient(123);
+ if (client == 0) {
+ //Handle failure here.
+ return;
+ } else {
+ Portal* newPortal = new Portal(client);
+
+ //Handle new client here.
+ this->portalsLock->lock();
+ this->portals->append(newPortal);
+ this->portalsLock->unlock();
+ }
+
+ QMutexLocker locker(this->portalsLock);
+
+ //Handle existing clients here
+
+ for (int i = 0; i < this->portals->size(); ++i) {
+ Portal* p = this->portals->at(i);
+
+ int retval = p->sendRecv();
+
+ if (retval <= 0) {
+ //disconnect
+ continue;
+ }
+
+ }
}
// Local Variables:
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits