From bc0450631f47df9659717b53a39808691ffd354d Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 17 May 1999 17:43:52 +0000 Subject: [PATCH] Tweaks to parallel construction tools. --- Tools/Construct/Parallel/client.cxx | 13 +++++++++---- Tools/Construct/Parallel/server.cxx | 6 +++--- Tools/Lib/Polygon/names.hxx | 22 +++++++++++----------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Tools/Construct/Parallel/client.cxx b/Tools/Construct/Parallel/client.cxx index fb4bc517e..da429673d 100644 --- a/Tools/Construct/Parallel/client.cxx +++ b/Tools/Construct/Parallel/client.cxx @@ -45,7 +45,7 @@ int make_socket (char *host, unsigned short int port) { { close(sock); perror("Cannot connect to stream socket"); - exit(-1); + return -1; } return sock; @@ -59,7 +59,10 @@ long int get_next_task( const string& host, int port ) { fd_set ready; char message[256]; - sock = make_socket( host.c_str(), port ); + while ( (sock = make_socket( host.c_str(), port )) < 0 ) { + // loop till we get a socket connection + sleep(1); + } // build a command string from the argv[]'s strcpy(message, "hello world!\n"); @@ -115,8 +118,10 @@ main(int argc, char *argv[]) { string host = argv[1]; int port = atoi( argv[2] ); - while ( true ) { - tile = get_next_task( host, port ); + while ( + (tile = get_next_task( host, port )) >= 0 + ) + { run_task( tile ); } } diff --git a/Tools/Construct/Parallel/server.cxx b/Tools/Construct/Parallel/server.cxx index 3cc05cdde..05f74ee51 100644 --- a/Tools/Construct/Parallel/server.cxx +++ b/Tools/Construct/Parallel/server.cxx @@ -160,7 +160,7 @@ long int get_next_tile( const string& work_base, const string& output_base ) } b = FGBucket( lon, lat ); - cout << "Bucket = " << b << endl; + cout << "Bucket = " << b << " (" << pass << ")" << endl; // increment to next tile FGBucket tmp( 0.0, lat ); @@ -203,7 +203,7 @@ int main( int argc, char **argv ) { cout << "socket is connected to port = " << port << endl; // Specify the maximum length of the connection queue - listen(sock, 3); + listen(sock, 10); for ( ;; ) { FD_ZERO(&ready); @@ -217,7 +217,7 @@ int main( int argc, char **argv ) { // get the next tile to work on next_tile = get_next_tile(work_base, output_base); - cout << "next tile = " << next_tile << endl;; + // cout << "next tile = " << next_tile << endl;; msgsock = accept(sock, 0, 0); // cout << "msgsock = " << msgsock << endl; diff --git a/Tools/Lib/Polygon/names.hxx b/Tools/Lib/Polygon/names.hxx index 52f3bb7ad..0b7f96bea 100644 --- a/Tools/Lib/Polygon/names.hxx +++ b/Tools/Lib/Polygon/names.hxx @@ -39,17 +39,17 @@ enum AreaType { SomeSortOfArea = 0, AirportKeepArea = 1, AirportIgnoreArea = 2, - OceanArea = 3, - LakeArea = 4, - DryLakeArea = 5, - IntLakeArea = 6, - ReservoirArea = 7, - IntReservoirArea = 8, - StreamArea = 9, - CanalArea = 10, - GlacierArea = 11, - MarshArea = 12, - DefaultArea = 13, + LakeArea = 3, + DryLakeArea = 4, + IntLakeArea = 5, + ReservoirArea = 6, + IntReservoirArea = 7, + StreamArea = 8, + CanalArea = 9, + GlacierArea = 10, + MarshArea = 11, + DefaultArea = 12, + OceanArea = 13, VoidArea = 9997, NullArea = 9998, UnknownArea = 9999