diff --git a/src/FDM/ExternalNet/ExternalNet.cxx b/src/FDM/ExternalNet/ExternalNet.cxx index e5e450908..eae848793 100644 --- a/src/FDM/ExternalNet/ExternalNet.cxx +++ b/src/FDM/ExternalNet/ExternalNet.cxx @@ -387,29 +387,29 @@ void FGExternalNet::init() { HTTPClient *http; sprintf( cmd, "/longitude-deg?value=%.8f", lon ); http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd ); - while ( !http->isDone() ) http->poll(0); + while ( !http->isDone(1000000) ) http->poll(0); delete http; sprintf( cmd, "/latitude-deg?value=%.8f", lat ); http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd ); - while ( !http->isDone() ) http->poll(0); + while ( !http->isDone(1000000) ) http->poll(0); delete http; sprintf( cmd, "/ground-m?value=%.8f", ground ); http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd ); - while ( !http->isDone() ) http->poll(0); + while ( !http->isDone(1000000) ) http->poll(0); delete http; sprintf( cmd, "/heading-deg?value=%.8f", heading ); http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd ); - while ( !http->isDone() ) http->poll(0); + while ( !http->isDone(1000000) ) http->poll(0); delete http; SG_LOG( SG_IO, SG_INFO, "before sending reset command." ); sprintf( cmd, "/reset?value=ground" ); http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd ); - while ( !http->isDone() ) http->poll(0); + while ( !http->isDone(1000000) ) http->poll(0); delete http; SG_LOG( SG_IO, SG_INFO, "Remote FDM init() finished." ); diff --git a/src/FDM/ExternalNet/ExternalNet.hxx b/src/FDM/ExternalNet/ExternalNet.hxx index 3943e1a89..7e36856a2 100644 --- a/src/FDM/ExternalNet/ExternalNet.hxx +++ b/src/FDM/ExternalNet/ExternalNet.hxx @@ -26,6 +26,8 @@ #include #include +#include // fine grained timing measurements + #include #include @@ -36,6 +38,7 @@ class HTTPClient : public netBufferChannel { bool done; + SGTimeStamp start; public: @@ -47,6 +50,8 @@ public: cchar* s = netFormat ( "GET %s HTTP/1.0\r\n\r\n", path ); bufferSend( s, strlen(s) ) ; + + start.stamp(); } virtual void handleBufferRead (netBuffer& buffer) @@ -62,6 +67,15 @@ public: } bool isDone() const { return done; } + bool isDone( long usec ) const { + SGTimeStamp now; + now.stamp(); + if ( (now - start) > usec ) { + return true; + } else { + return done; + } + } };