From cf04dd313578a009b0e9708eb49b97634c15e6ae Mon Sep 17 00:00:00 2001 From: Ralf Gerlich Date: Wed, 2 Jan 2008 11:23:39 -0800 Subject: [PATCH 1/3] Fixed select()-call in fgfs-tools-{client,server} which occasionally led to lockup. --- src/BuildTiles/Parallel/client.cxx | 2 +- src/BuildTiles/Parallel/server.cxx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BuildTiles/Parallel/client.cxx b/src/BuildTiles/Parallel/client.cxx index a800394f..c19e763c 100644 --- a/src/BuildTiles/Parallel/client.cxx +++ b/src/BuildTiles/Parallel/client.cxx @@ -159,7 +159,7 @@ long int get_next_task( const string& host, int port, long int last_tile ) { FD_SET(sock, &ready); // block until input from sock - select(32, &ready, 0, 0, NULL); + select(sock+1, &ready, 0, 0, NULL); cout << " received reply" << endl; if ( FD_ISSET(sock, &ready) ) { diff --git a/src/BuildTiles/Parallel/server.cxx b/src/BuildTiles/Parallel/server.cxx index 28317087..8739c53b 100644 --- a/src/BuildTiles/Parallel/server.cxx +++ b/src/BuildTiles/Parallel/server.cxx @@ -364,7 +364,7 @@ int main( int argc, char **argv ) { FD_SET(sock, &ready); // block until we get some input on sock - select(32, &ready, 0, 0, NULL); + select(sock+1, &ready, 0, 0, NULL); if ( FD_ISSET(sock, &ready) ) { // printf("%d %d Incomming message --> ", getpid(), pid); @@ -409,6 +409,7 @@ int main( int argc, char **argv ) { } } else { // This is the child + close(sock); // cout << "new process started to handle new connection for " // << next_tile << endl; From 0a32b5f3bc1bf76b6de81988282fa27635bcf68c Mon Sep 17 00:00:00 2001 From: Ralf Gerlich Date: Wed, 2 Jan 2008 23:55:13 -0800 Subject: [PATCH 2/3] Avoid SIGSEGV in fgfs-tools-client when the results file is not found. --- src/BuildTiles/Parallel/client.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BuildTiles/Parallel/client.cxx b/src/BuildTiles/Parallel/client.cxx index c19e763c..1c3734e5 100644 --- a/src/BuildTiles/Parallel/client.cxx +++ b/src/BuildTiles/Parallel/client.cxx @@ -286,6 +286,10 @@ bool construct_tile( const SGBucket& b, system( command.c_str() ); FILE *fp = fopen( result_file.c_str(), "r" ); + if ( fp == NULL) { + cout << "Missing results file " << result_file << endl; + return false; + } char line[256]; while ( fgets( line, 256, fp ) != NULL ) { string line_str = line; From 1a4b3a1d9895b4404fc6e985df9f963ea02b2627 Mon Sep 17 00:00:00 2001 From: Ralf Gerlich Date: Thu, 3 Jan 2008 00:22:13 -0800 Subject: [PATCH 3/3] Fixed filedescriptor overflow in fgfs-tools-client which led the client to think that the MASTER_ON file did not exist. --- src/BuildTiles/Parallel/client.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/BuildTiles/Parallel/client.cxx b/src/BuildTiles/Parallel/client.cxx index 1c3734e5..51c47d6d 100644 --- a/src/BuildTiles/Parallel/client.cxx +++ b/src/BuildTiles/Parallel/client.cxx @@ -239,10 +239,12 @@ static bool must_generate( const SGBucket& b ) { } if ( have_btg && src_stat.st_mtime>btg_stat.st_mtime ) { cout << " File " << file << " is newer than btg-file => rebuild\n"; + closedir(loaddir); return true; } if ( have_stg && src_stat.st_mtime>stg_stat.st_mtime ) { cout << " File " << file << " is newer than stg-file => rebuild\n"; + closedir(loaddir); return true; } /* Ignore elevation data, as it is not used if we have no @@ -253,6 +255,7 @@ static bool must_generate( const SGBucket& b ) { continue; if ( !(have_stg && have_btg) ) { cout << " There is source-data (" << file << ") for tile " << b.gen_index_str() << " but .btg or .stg is missing => build\n"; + closedir(loaddir); return true; } }