Revision: 8155
http://playerstage.svn.sourceforge.net/playerstage/?rev=8155&view=rev
Author: hsujohnhsu
Date: 2009-07-30 00:58:07 +0000 (Thu, 30 Jul 2009)
Log Message:
-----------
fix startup client wait loop.
Modified Paths:
--------------
code/gazebo/trunk/libgazebo/Client.cc
Modified: code/gazebo/trunk/libgazebo/Client.cc
===================================================================
--- code/gazebo/trunk/libgazebo/Client.cc 2009-07-29 22:47:43 UTC (rev
8154)
+++ code/gazebo/trunk/libgazebo/Client.cc 2009-07-30 00:58:07 UTC (rev
8155)
@@ -138,41 +138,41 @@
try
{
simulationIface.Open(this,"default");
- }
- catch (std::string e)
- {
- std::cerr << "Error Opening SimulationIface [" << e << "]\n";
- exit(0);
- }
- // check realTime for updates
- simulationIface.Lock(1);
- double simTime0 = simulationIface.data->realTime;
- simulationIface.Unlock();
- double simTime1 = simTime0;
-
- struct timeval tv;
- gettimeofday(&tv, NULL);
- double start_time = tv.tv_sec + tv.tv_usec * 1e-6;
- double current_time = start_time;
- const double timeout = 1; // timeout, disconnect and reconnect client
- while(current_time - start_time < timeout)
- {
- usleep(200000);
+ // check realTime for updates
simulationIface.Lock(1);
- simTime1 = simulationIface.data->realTime;
+ double simTime0 = simulationIface.data->realTime;
simulationIface.Unlock();
- if (simTime1 != simTime0)
+ double simTime1 = simTime0;
+
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ double start_time = tv.tv_sec + tv.tv_usec * 1e-6;
+ double current_time = start_time;
+ const double timeout = 1; // timeout, disconnect and reconnect client
+ while(current_time - start_time < timeout)
{
- simulationIfaceIsValid = true;
- break;
+ usleep(200000);
+ simulationIface.Lock(1);
+ simTime1 = simulationIface.data->realTime;
+ simulationIface.Unlock();
+ if (simTime1 != simTime0)
+ {
+ simulationIfaceIsValid = true;
+ break;
+ }
+ //std::cout << "realTime has not changed, retrying
SimulationIface->data->realTime:" << simTime1 << " : " << simTime0 << std::endl;
+ gettimeofday(&tv, NULL);
+ current_time = tv.tv_sec + tv.tv_usec * 1e-6;
}
- //std::cout << "realTime has not changed, retrying
SimulationIface->data->realTime:" << simTime1 << " : " << simTime0 << std::endl;
- gettimeofday(&tv, NULL);
- current_time = tv.tv_sec + tv.tv_usec * 1e-6;
+ if (!simulationIfaceIsValid)
+ {
+ this->Disconnect();
+ }
}
- if (!simulationIfaceIsValid)
+ catch (std::string e)
{
- this->Disconnect();
+ std::cerr << "Error Opening SimulationIface [" << e << "]\n";
+ //exit(0); // don't exit, retry
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit