From: <he...@us...> - 2011-04-21 15:29:31
|
Revision: 270 http://simspark.svn.sourceforge.net/simspark/?rev=270&view=rev Author: hedayat Date: 2011-04-21 15:29:25 +0000 (Thu, 21 Apr 2011) Log Message: ----------- Do not block on sending data to clients over network! Modified Paths: -------------- trunk/spark/ChangeLog trunk/spark/NEWS trunk/spark/RELEASE trunk/spark/lib/oxygen/simulationserver/netcontrol.cpp trunk/spark/lib/oxygen/simulationserver/netcontrol.h Modified: trunk/spark/ChangeLog =================================================================== --- trunk/spark/ChangeLog 2011-04-21 13:55:47 UTC (rev 269) +++ trunk/spark/ChangeLog 2011-04-21 15:29:25 UTC (rev 270) @@ -1,3 +1,13 @@ +2011-04-21 Hedayat Vatankhah <hed...@gm...> + + * NEWS: + * RELEASE: + - Added info about the network change for 0.2.2 release + + * lib/oxygen/simulationserver/netcontrol.cpp (NetControl::SendClientMessage): + - don't block on sending data to agents. if a receiver cannot receive data, + it'll lose future messages until it can receive furthur messages + 2011-04-20 Hedayat Vatankhah <hed...@gm...> * cmake/FindODE.cmake: Modified: trunk/spark/NEWS =================================================================== --- trunk/spark/NEWS 2011-04-21 13:55:47 UTC (rev 269) +++ trunk/spark/NEWS 2011-04-21 15:29:25 UTC (rev 270) @@ -15,6 +15,8 @@ - HingePerceptor can report torque - Better Performance - New timing system result in more cleaner code and prevent wasting CPU time +- Do not block on sending data to clients. Previously, simulator would block on + send() until it can send all data to clients. [0.2.1] This release of simspark is prepared for RoboCup 2010 competitions in Singapore. Modified: trunk/spark/RELEASE =================================================================== --- trunk/spark/RELEASE 2011-04-21 13:55:47 UTC (rev 269) +++ trunk/spark/RELEASE 2011-04-21 15:29:25 UTC (rev 270) @@ -16,6 +16,8 @@ - HingePerceptor can report torque - Better Performance - New timing system result in more cleaner code and prevent wasting CPU time +- Do not block on sending data to clients. Previously, simulator would block on + send() until it can send all data to clients. You can get the package on the Simspark page on SourceForge at http://sourceforge.net/projects/simspark/ Modified: trunk/spark/lib/oxygen/simulationserver/netcontrol.cpp =================================================================== --- trunk/spark/lib/oxygen/simulationserver/netcontrol.cpp 2011-04-21 13:55:47 UTC (rev 269) +++ trunk/spark/lib/oxygen/simulationserver/netcontrol.cpp 2011-04-21 15:29:25 UTC (rev 270) @@ -253,6 +253,7 @@ << endl; mClientId++; + mSendBuffers.resize(mClientId); ClientConnect(client); } @@ -318,12 +319,33 @@ // udp client if (mSocket.get() != 0) { - rval = mSocket->send(msg.data(), msg.size(), client->addr); + do + { + rval = mSocket->send(msg.data(), msg.size(), + client->addr, rcss::net::Socket::DONT_CHECK); + } + while (rval == -1 && errno == EINTR); + // don't retry unless an interrupt is received } } else { // tcp client - rval = socket->send(msg.data(), msg.size()); + const string &sendMsg = mSendBuffers[client->id].empty() ? msg + : mSendBuffers[client->id]; + unsigned sent = 0; + do + { + rval = socket->send(sendMsg.data() + sent, + sendMsg.size() - sent, 0, + rcss::net::Socket::DONT_CHECK); + if ( rval > 0 ) + sent += rval; + } + while (sent < sendMsg.size() && (rval != -1 || errno == EINTR)); + // try to send unless an EINTR error happens + + mSendBuffers[client->id].assign(sendMsg.data() + sent, + sendMsg.size() - sent); } if (rval < 0) Modified: trunk/spark/lib/oxygen/simulationserver/netcontrol.h =================================================================== --- trunk/spark/lib/oxygen/simulationserver/netcontrol.h 2011-04-21 13:55:47 UTC (rev 269) +++ trunk/spark/lib/oxygen/simulationserver/netcontrol.h 2011-04-21 15:29:25 UTC (rev 270) @@ -22,6 +22,7 @@ #include "simcontrolnode.h" #include "netbuffer.h" +#include <vector> #include <rcssnet/socket.hpp> #include <boost/shared_array.hpp> #include <oxygen/oxygen_defines.h> @@ -198,6 +199,9 @@ /** the size of the allocated receive buffer */ int mBufferSize; + /** a buffer to store partial messages to be sent */ + std::vector<std::string> mSendBuffers; + /** the receive buffer */ boost::shared_array<char> mBuffer; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |