Revision: 40825
http://brlcad.svn.sourceforge.net/brlcad/?rev=40825&view=rev
Author: davidloman
Date: 2010-09-29 15:00:48 +0000 (Wed, 29 Sep 2010)
Log Message:
-----------
Disconnect by closing the FD outside of the PortalManager causes select to
throw errors. Fix is to pass a PortalManager pointer to each Portal object.
This allows Portal to call PortalManager::disconnect and pass itself in.
PortalManager can then do all the voodoo that it needs to do.
Modified Paths:
--------------
rt^3/trunk/include/Portal.h
rt^3/trunk/src/libNet/Portal.cxx
rt^3/trunk/src/libNet/PortalManager.cxx
Modified: rt^3/trunk/include/Portal.h
===================================================================
--- rt^3/trunk/include/Portal.h 2010-09-29 14:31:43 UTC (rev 40824)
+++ rt^3/trunk/include/Portal.h 2010-09-29 15:00:48 UTC (rev 40825)
@@ -34,6 +34,7 @@
#include "brlcad/pkg.h"
#include <QtCore/QString>
+class PortalManager;
class Portal : public INetMsgHandler
{
@@ -49,7 +50,7 @@
bool handleNetMsg(NetMsg* msg);
protected:
- Portal(PkgTcpClient* client, struct pkg_switch* table);
+ Portal(PortalManager* pm, PkgTcpClient* client, struct pkg_switch* table);
/*
* Returns:
@@ -61,6 +62,7 @@
private:
+ PortalManager* pm;
struct pkg_switch* callbackTable;
PkgTcpClient* pkgClient;
QString remoteNodeName;
Modified: rt^3/trunk/src/libNet/Portal.cxx
===================================================================
--- rt^3/trunk/src/libNet/Portal.cxx 2010-09-29 14:31:43 UTC (rev 40824)
+++ rt^3/trunk/src/libNet/Portal.cxx 2010-09-29 15:00:48 UTC (rev 40825)
@@ -24,6 +24,7 @@
*/
#include "Portal.h"
+#include "PortalManager.h"
#include "Logger.h"
#include "brlcad/bu.h"
#include "NetMsgFactory.h"
@@ -32,15 +33,13 @@
#include "RemoteNodenameSetMsg.h"
#include "TypeOnlyMsg.h"
-Portal::Portal(PkgTcpClient* client, struct pkg_switch* table) {
+Portal::Portal(PortalManager* pm, PkgTcpClient* client, struct pkg_switch*
table):
+pm(pm), pkgClient(client), callbackTable(table), log(Logger::getInstance()),
handshakeComplete(false)
+{
this->remoteNodeName = "NotSetYet-" + QUuid::createUuid().toString();
- this->pkgClient = client;
- this->callbackTable = table;
+
//set the struct's userdata
this->callbackTable[0].pks_user_data = this;
-
- this->log = Logger::getInstance();
- this->handshakeComplete = false;
}
Portal::~Portal() {
@@ -216,8 +215,9 @@
void
Portal::disconnect()
{
- close(this->pkgClient->getFileDescriptor());
+ this->pm->disconnect(this);
}
+
// Local Variables: ***
// mode: C++ ***
// tab-width: 8 ***
Modified: rt^3/trunk/src/libNet/PortalManager.cxx
===================================================================
--- rt^3/trunk/src/libNet/PortalManager.cxx 2010-09-29 14:31:43 UTC (rev
40824)
+++ rt^3/trunk/src/libNet/PortalManager.cxx 2010-09-29 15:00:48 UTC (rev
40825)
@@ -28,6 +28,9 @@
#include "NetMsgFactory.h"
#include "PkgTcpClient.h"
+#include <stdio.h>
+#include <errno.h>
+
PortalManager::PortalManager(quint16 port) :
ControlledThread("PortalManager") {
this->port = port;
@@ -129,7 +132,8 @@
bu_log("Selector Error: ENOMEM: unable to allocate
memory for internal tables.\n");
}*/
- this->log->logERROR("PortalManager", "Selector Error.");
+/// this->log->logERROR("PortalManager", "Selector Error.");
+ bu_log("Selector error: %d\n", errno);
break;
}
@@ -247,7 +251,7 @@
Portal*
PortalManager::makeNewPortal(PkgTcpClient* client, struct pkg_switch* table) {
- Portal* p = new Portal(client, table);
+ Portal* p = new Portal(this, client, table);
if (p == 0) {
return 0;
@@ -293,7 +297,8 @@
return table;
}
-void PortalManager::closeFD(int fd, QString logComment) {
+void
+PortalManager::closeFD(int fd, QString logComment) {
close(fd);
this->masterFDSLock.lock();
@@ -311,6 +316,13 @@
}
}
+void
+PortalManager::disconnect(Portal* p)
+{
+ int fd = p->pkgClient->getFileDescriptor();
+ this->closeFD(fd, "Disconnect requested.");
+}
+
// Local Variables:
// tab-width: 8
// mode: C++
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