You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by ve...@apache.org on 2012/08/23 18:48:30 UTC
svn commit: r1376589 - in /incubator/etch/trunk:
binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/
binding-cpp/runtime/src/main/support/ binding-cpp/runtime/src/main/transport/
binding-cpp/runtime/src/test/transport/ exampl...
Author: veithm
Date: Thu Aug 23 16:48:30 2012
New Revision: 1376589
URL: http://svn.apache.org/viewvc?rev=1376589&view=rev
Log:
ETCH-216 Small improvement in TcpConnection
Avoiding QNX Sockets to fail while setting properties
Fixed small bugs in code generation
Change-Id: I2fe3a9dcae70525544f774f7ffc07facae9234fb
Modified:
incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_cpp.vm
incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchTcpConnectionTest.cpp
incubator/etch/trunk/examples/helloworld/cpp/build.xml
Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_cpp.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_cpp.vm?rev=1376589&r1=1376588&r2=1376589&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_cpp.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_cpp.vm Thu Aug 23 16:48:30 2012
@@ -182,6 +182,7 @@ status_t $clname::newListener(EtchRuntim
//create valuefactory instance
ValueFactory${i}* vf = new ValueFactory${i}(uri);
+ stack->setValueFactory(vf);
EtchObject* vfobj = (EtchObject*) vf;
EtchObject* resobj = NULL;
res->put(EtchTransport<ValueFactory${i}>::VALUE_FACTORY(), vfobj, resobj);
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp?rev=1376589&r1=1376588&r2=1376589&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp Thu Aug 23 16:48:30 2012
@@ -33,6 +33,7 @@ EtchStack::EtchStack() : EtchObject()
, mTransportPacket(NULL)
, mTransportMessage(NULL)
, mResources(NULL)
+ , mValueFactory(NULL)
, mMailboxManager(NULL)
, mDeliveryService(NULL)
, mStub(NULL)
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp?rev=1376589&r1=1376588&r2=1376589&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp Thu Aug 23 16:48:30 2012
@@ -257,46 +257,49 @@ capu::bool_t EtchTcpConnection::isStarte
void EtchTcpConnection::run() {
+ status_t status;
capu::bool_t first = true;
while (mIsStarted) {
- if (openSocket(!first) != ETCH_OK) {
+ status = openSocket(!first);
+ if (status != ETCH_OK) {
CAPU_LOG_ERROR(mRuntime->getLogger(), "EtchTcpConnection", "%s : %d => Socket has not been successfully opened", mHost.c_str(), mPort);
break;
}
- status_t res = setupSocket();
- if (res != ETCH_OK) {
+ status = setupSocket();
+ if (status != ETCH_OK) {
close();
break;
}
CAPU_LOG_DEBUG(mRuntime->getLogger(), "EtchTcpConnection", "%s : %d => Socket has been opened and connection has been successfully established and start reading", mHost.c_str(), mPort);
fireUp();
CAPU_LOG_DEBUG(mRuntime->getLogger(), "EtchTcpConnection", "%s : %d => FireUp was send to the Stack", mHost.c_str(), mPort);
- if (readSocket() != ETCH_OK) {
- close();
- CAPU_LOG_TRACE(mRuntime->getLogger(), "EtchTcpConnection", "%s : %d => Connection closing", mHost.c_str(), mPort);
- break;
- }
+ status = readSocket();
CAPU_LOG_TRACE(mRuntime->getLogger(), "EtchTcpConnection", "%s : %d => Connection closing", mHost.c_str(), mPort);
fireDown();
CAPU_LOG_DEBUG(mRuntime->getLogger(), "EtchTcpConnection", "%s : %d => FireDown was send to the Stack", mHost.c_str(), mPort);
close();
first = false;
}
- mIsStarted = false;
}
status_t EtchTcpConnection::setupSocket() {
- if (mSocket->setBufferSize(mOptions.getBufferSize()) != ETCH_OK)
- return ETCH_ERROR;
- if (mSocket->setKeepAlive((mOptions.getKeepAlive() != 0)) != ETCH_OK)
+ if (mOptions.getBufferSize() != 0) {
+ if (mSocket->setBufferSize(mOptions.getBufferSize()) != ETCH_OK) {
+ return ETCH_ERROR;
+ }
+ }
+ if (mSocket->setKeepAlive((mOptions.getKeepAlive() != 0)) != ETCH_OK) {
return ETCH_ERROR;
- if (mSocket->setLingerOption((mOptions.getLingerTime() >= 0), mOptions.getLingerTime()) != ETCH_OK)
+ }
+ if (mSocket->setLingerOption((mOptions.getLingerTime() >= 0), mOptions.getLingerTime()) != ETCH_OK) {
return ETCH_ERROR;
- if (mSocket->setNoDelay((mOptions.getNoDelay() != 0)) != ETCH_OK)
+ }
+ if (mSocket->setNoDelay((mOptions.getNoDelay() != 0)) != ETCH_OK) {
return ETCH_ERROR;
+ }
CAPU_LOG_TRACE(mRuntime->getLogger(), "EtchTcpConnection", "%s : %d => Settings for socket has been successfully configured", mHost.c_str(), mPort);
return ETCH_OK;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp?rev=1376589&r1=1376588&r2=1376589&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp Thu Aug 23 16:48:30 2012
@@ -65,7 +65,7 @@ status_t EtchTcpTransportFactory::newTra
return ETCH_EUNIMPL;
} else {
// TODO add runtime
- c = new EtchTcpConnection(NULL, (EtchSocket*) socket, &u);
+ c = new EtchTcpConnection(mRuntime, (EtchSocket*) socket, &u);
}
stack->setTransportData(c);
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchTcpConnectionTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchTcpConnectionTest.cpp?rev=1376589&r1=1376588&r2=1376589&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchTcpConnectionTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchTcpConnectionTest.cpp Thu Aug 23 16:48:30 2012
@@ -50,18 +50,22 @@ public:
class MockListener : public virtual EtchSessionListener<EtchSocket> {
public:
+ MockListener() : socket(NULL) {}
- //Communication Test Between Peers
+ ~MockListener() {
+ delete socket;
+ }
EtchResources resources;
+ EtchSocket* socket;
+ //Communication Test Between Peers
status_t sessionAccepted(EtchSocket* connection) {
EtchString _socket("socket");
EtchObject *tmp;
resources.put(_socket, connection, tmp);
connection->send((unsigned char *) "mock", 4);
- capu::Thread::Sleep(1000);
- delete connection;
+ socket = connection;
return ETCH_OK;
}
@@ -113,15 +117,15 @@ TEST_F(EtchTcpConnectionTest, isStartedT
EtchSessionData* mPacketizer = new MockPacketizer();
//START THE LISTENER
listener->setSession(mSessionListener);
- listener->transportControl(new EtchString(EtchTcpListener::START_AND_WAIT_UP()), new EtchInt32(2000));
+ EXPECT_EQ(ETCH_OK, listener->transportControl(new EtchString(EtchTcpListener::START_AND_WAIT_UP()), new EtchInt32(400000)));
//START THE TRANSPORT
conn->setSession(mPacketizer);
- conn->transportControl(new EtchString(EtchTcpConnection::START_AND_WAIT_UP()), new EtchInt32(2000));
+ EXPECT_EQ(ETCH_OK, conn->transportControl(new EtchString(EtchTcpConnection::START_AND_WAIT_UP()), new EtchInt32(400000)));
EXPECT_TRUE(conn->isStarted());
//STOP THE TRANSPORT
- conn->transportControl(new EtchString(EtchTcpConnection::STOP_AND_WAIT_DOWN()), new EtchInt32(2000));
+ EXPECT_EQ(ETCH_OK, conn->transportControl(new EtchString(EtchTcpConnection::STOP_AND_WAIT_DOWN()), new EtchInt32(400000)));
//STOP THE LISTENER
- listener->transportControl(new EtchString(EtchTcpListener::STOP_AND_WAIT_DOWN()), new EtchInt32(2000));
+ EXPECT_EQ(ETCH_OK, listener->transportControl(new EtchString(EtchTcpListener::STOP_AND_WAIT_DOWN()), new EtchInt32(400000)));
EXPECT_FALSE(conn->isStarted());
conn->setSession(NULL);
Modified: incubator/etch/trunk/examples/helloworld/cpp/build.xml
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/cpp/build.xml?rev=1376589&r1=1376588&r2=1376589&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/cpp/build.xml (original)
+++ incubator/etch/trunk/examples/helloworld/cpp/build.xml Thu Aug 23 16:48:30 2012
@@ -95,7 +95,7 @@
<target name="build-cpp" depends="generate-sources" if="USE.cmake">
<cmake srcdir="${basedir}" bindir="${basedir}/target" buildtype="Debug" >
- <generator name="Visual Studio 8 2005" platform="windows" />
+ <!-- <generator name="Visual Studio 8 2005" platform="windows" />-->
<variable name="ETCH_INCLUDE_CAPU_DIR" type="PATH" value="${Etch.basedir}/binding-cpp/runtime/lib/capu/deliverable/capu/include/capu" />
<variable name="ETCH_HOME" type="PATH" value="${etch.home}" />
</cmake>
@@ -103,14 +103,10 @@
<fileset dir="${target}" >
<include name="helloworld-client" />
<include name="helloworld-server" />
- <include name="debug/helloworld-client.exe" />
- <include name="debug/helloworld-server.exe" />
+ <include name="Debug/helloworld-client.exe" />
+ <include name="Debug/helloworld-server.exe" />
</fileset>
</copy>
- <delete file="${target}/helloworld-client" quiet="true" />
- <delete file="${target}/helloworld-server" quiet="true" />
- <delete file="${target}/debug/helloworld-client.exe" quiet="true" />
- <delete file="${target}/debug/helloworld-server.exe" quiet="true" />
<chmod perm="+x">
<fileset dir="${bin}">
<include name="helloworld-client" />