Re: [Flightgear-devel] Patch to protect terrasync SVN from ^C

2010-03-03 Thread Frederic Bouvier
Hi Jari,

- Jari Häkkinen a écrit :

 Great, I haven't had an opportunity to run the new version yet. I took
 time to compile though, and there is a problem compiling terrasync.cxx
 on mac because of Apples typedef of the signal handler. I attached a 
 small fix.

Your mail remind me I had a fix to commit. Your patch and the fix for the
naming problem are commited now

Thanks,
-Fred 

-- 
Frédéric Bouvier
http://my.fotolia.com/frfoto/  Photo gallery - album photo
http://fgsd.sourceforge.net/   FlightGear Scenery Designer


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Patch to protect terrasync SVN from ^C

2010-03-01 Thread Martin Spott
I'm expieriencing difficulties to compile 'terrasync' after the latest
patch. While PLIB's socket seems to be the target, the type socket
interferes with the system headers:

g++ -g -O3 -march=opteron -DHAVE_CONFIG_H -I. -I../../src/Include  
-I/usr/include/subversion-1  -I/usr/include/apr-1.0  -I/opt/gnu/include 
-I/usr/local/include -I/opt/Boost/include/boost-1_37 -I/opt/FlightGear/include  
-g -O2 -I/opt/FlightGear -D_REENTRANT -c -o terrasync.o terrasync.cxx
terrasync.cxx:118: error: 'netSocket socket' redeclared as different kind of 
symbol
/usr/include/sys/socket.h:101: error: previous declaration of 'int socket(int, 
int, int)'
terrasync.cxx: In function 'void terminate_request_handler(int)':
terrasync.cxx:298: error: request for member 'close' in 'socket', which is of 
non-class type 'int ()(int, int, int)throw ()'
[...]


The following simple patch at least permits to compile - is this the
way it's meant to be ?

--- terrasync.cxx.original  2010-03-01 08:44:20.0 +0100
+++ terrasync.cxx   2010-03-01 11:35:55.975624335 +0100
@@ -115,7 +115,7 @@
 dequestring waitingTiles;
 typedef mapstring,time_t CompletedTiles;
 CompletedTiles completedTiles;
-netSocket socket;
+netSocket netSocket;
 
 #ifdef HAVE_SVN_CLIENT_H
 
@@ -295,7 +295,7 @@
 write(1, msg, sizeof(msg) - 1);
 terminating = true;
 signal(param, prior_signal_handlers[param]);
-socket.close();
+netSsocket.close();
 }
 
 
@@ -517,12 +517,12 @@
 // Must call this before any other net stuff
 netInit( argc,argv );
 
-if ( ! socket.open( false ) ) {  // open a UDP socket
+if ( ! netSocket.open( false ) ) {  // open a UDP socket
 printf(error opening socket\n);
 return -1;
 }
 
-if ( socket.bind( host, port ) == -1 ) {
+if ( netSocket.bind( host, port ) == -1 ) {
 printf(error binding to port %d\n, port);
 return -1;
 }
@@ -571,8 +571,8 @@
 if (verbose  waitingTiles.empty()) {
 cout  Idle; waiting for FlightGear position\n;
 }
-socket.setBlocking(waitingTiles.empty());
-len = socket.recv(msg, maxlen, 0);
+netSocket.setBlocking(waitingTiles.empty());
+len = netSocket.recv(msg, maxlen, 0);
 if (len = 0) {
 msg[len] = '\0';
 recv_msg = true;


Cheers,
Martin.
-- 
 Unix _IS_ user friendly - it's just selective about who its friends are !
--

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Patch to protect terrasync SVN from ^C

2010-03-01 Thread Martin Spott
  ooops !

Martin Spott wrote:

 @@ -295,7 +295,7 @@
 write(1, msg, sizeof(msg) - 1);
 terminating = true;
 signal(param, prior_signal_handlers[param]);
 -socket.close();
 +netSsocket.close();
  ^^

Sorry,
Martin.
-- 
 Unix _IS_ user friendly - it's just selective about who its friends are !
--

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Patch to protect terrasync SVN from ^C

2010-03-01 Thread Frederic Bouvier
Hi Martin,

- Martin Spott a écrit :

 I'm expieriencing difficulties to compile 'terrasync' after the
 latest
 patch. While PLIB's socket seems to be the target, the type socket
 interferes with the system headers:
 
 g++ -g -O3 -march=opteron -DHAVE_CONFIG_H -I. -I../../src/Include 
 -I/usr/include/subversion-1  -I/usr/include/apr-1.0 
 -I/opt/gnu/include -I/usr/local/include
 -I/opt/Boost/include/boost-1_37 -I/opt/FlightGear/include  -g -O2
 -I/opt/FlightGear -D_REENTRANT -c -o terrasync.o terrasync.cxx
 terrasync.cxx:118: error: 'netSocket socket' redeclared as different
 kind of symbol
 /usr/include/sys/socket.h:101: error: previous declaration of 'int
 socket(int, int, int)'
 terrasync.cxx: In function 'void terminate_request_handler(int)':
 terrasync.cxx:298: error: request for member 'close' in 'socket',
 which is of non-class type 'int ()(int, int, int)throw ()'
 [...]
 
 
 The following simple patch at least permits to compile - is this the
 way it's meant to be ?

Sorry I created a name conflict under unix. Obviously, the variable name should 
be changed, but I am surprised you could name a variable with its type name. I 
didn't want the original 's' be in the global namespace, and that's why I 
renamed it. I am inclined to name the variable theSocket or something like that.

Anyway, I won't be able to commit anything until this evening (CET time).

Regards,
-Fred

-- 
Frédéric Bouvier
http://my.fotolia.com/frfoto/  Photo gallery - album photo
http://fgsd.sourceforge.net/   FlightGear Scenery Designer


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Patch to protect terrasync SVN from ^C

2010-03-01 Thread Martin Spott
Frederic Bouvier wrote:

 Anyway, I won't be able to commit anything until this evening (CET time).

No problem,
Martin.
-- 
 Unix _IS_ user friendly - it's just selective about who its friends are !
--

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Patch to protect terrasync SVN from ^C

2010-02-28 Thread Alex Perry
Done.  Also added the modified source file.

On Sun, Feb 28, 2010 at 12:09 AM, Frederic Bouvier fredfgf...@free.fr wrote:
 Hi Alex,
 Please resend this patch gzip and attached. I can't use it as it is.

 -Fred


 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Flightgear-devel mailing list
 Flightgear-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/flightgear-devel



terrasync-signals.patch.gz
Description: GNU Zip compressed data
// terrasync.cxx -- JIT scenery fetcher
//
// Written by Curtis Olson, started November 2002.
//
// Copyright (C) 2002  Curtis L. Olson  - http://www.flightgear.org/~curt
// Copyright (C) 2008  Alexander R. Perry alex.pe...@ieee.org
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
// $Id: terrasync.cxx,v 1.28 2010/01/23 22:27:38 fredb Exp $

#ifdef HAVE_CONFIG_H
#include config.h
#endif

#ifdef HAVE_WINDOWS_H
#include windows.h
#endif

#ifdef __MINGW32__
#include time.h
#include unistd.h
#endif

#include stdlib.h // atoi() atof() abs() system()
#include signal.h // signal()

#include simgear/compiler.h

#include iostream
#include fstream
#include string
#include deque
#include map

#include plib/netSocket.h
#include plib/ul.h

#include simgear/bucket/newbucket.hxx
#include simgear/misc/sg_path.hxx

#ifdef HAVE_SVN_CLIENT_H
#  ifdef HAVE_LIBSVN_CLIENT_1
#include svn_auth.h
#include svn_client.h
#include svn_cmdline.h
#include svn_pools.h
#  else
#undef HAVE_SVN_CLIENT_H
#  endif
#endif

using namespace std;

const char* source_base = NULL;
const char* svn_base =
  http://terrascenery.googlecode.com/svn/trunk/data/Scenery;;
const char* rsync_base = scenery.flightgear.org::Scenery;
const char* dest_base = terrasyncdir;
const char* rsync_cmd = 
rsync --verbose --archive --delete --perms --owner --group;

#ifdef HAVE_SVN_CLIENT_H
bool use_svn = true;
#else
bool use_svn = false;
const char* svn_cmd = svn checkout;
#endif

// display usage
static void usage( const string prog ) {
cout  
Usage:  terrasync [options]\n
Options:  \n
 -d dest   destination directory [required]\n
 -R  transport using pipe to rsync\n
 -S  transport using built-in svn\n
 -p port   listen on UDP port [default: 5501]\n
 -s source source base [default: '']\n
 -pid pidfile  write PID to file\n
 -v  be more verbose\n
;

#ifdef HAVE_SVN_CLIENT_H
cout  (defaults to the built in subversion)  endl;
#else
cout  (defaults to rsync, using external commands)  endl;
#endif

  cout  \nExample:\n
pid=$(cat $pidfile 2/dev/null)\n
if test -n \$pid\  kill -0 $pid ; then\n
echo \terrasync already running: $pid\\n
else\n
nice /games/sport/fgs/utils/TerraSync/terrasync \\\n
  -v -pid $pidfile -S -p 5500 -d /games/orig/terrasync \n
fi  endl;

}

std::dequestd::string waitingTiles;
typedef std::mapstd::string,time_t CompletedTiles;
CompletedTiles completedTiles;

#ifdef HAVE_SVN_CLIENT_H

// Things we need for doing subversion checkout - often
apr_pool_t *mysvn_pool = NULL;
svn_client_ctx_t *mysvn_ctx = NULL;
svn_opt_revision_t *mysvn_rev = NULL;
svn_opt_revision_t *mysvn_rev_peg = NULL;

static const svn_version_checklist_t mysvn_checklist[] = {
{ svn_subr,   svn_subr_version },
{ svn_client, svn_client_version },
{ svn_wc, svn_wc_version },
{ svn_ra, svn_ra_version },
{ svn_delta,  svn_delta_version },
{ svn_diff,   svn_diff_version },
{ NULL, NULL }
};

// Configure our subversion session
int mysvn_setup(void) {
// Are we already prepared?
if (mysvn_pool) return EXIT_SUCCESS;
// No, so initialize svn internals generally
#ifdef _MSC_VER
// there is a segfault when providing an error stream.
//  Apparently, calling setvbuf with a nul buffer is
//  not supported under msvc 7.1 ( code inside svn_cmdline_init )
if (svn_cmdline_init(terrasync, 0) != EXIT_SUCCESS)
return EXIT_FAILURE;
#else
if 

Re: [Flightgear-devel] Patch to protect terrasync SVN from ^C

2010-02-28 Thread Tim Moore
Whoops, I'm a bit late with my comments, but all the same...

You can't safely use C++ stream functions in a signal handler.

Why does terrasync need to be protected from interruption like this? Does
the SVN update really get corrupted if it is interrupted?

Tim

On Sun, Feb 28, 2010 at 6:50 AM, Alex Perry alex.pe...@ieee.org wrote:

 Index: terrasync.cxx
 ===
 RCS file: /var/cvs/FlightGear-0.9/source/utils/TerraSync/terrasync.cxx,v
 retrieving revision 1.28
 diff -u -r1.28 terrasync.cxx
 --- terrasync.cxx   23 Jan 2010 22:27:38 -  1.28
 +++ terrasync.cxx   28 Feb 2010 05:49:01 -
 @@ -35,6 +35,7 @@
  #endif

  #include stdlib.h // atoi() atof() abs() system()
 +#include signal.h // signal()

  #include simgear/compiler.h

 @@ -270,8 +271,23 @@
  }


 +bool terminating = false;
 +sighandler_t prior_signal_handlers[32];
 +int termination_triggering_signals[] =
 +  {SIGHUP, SIGINT, SIGQUIT, SIGKILL, 0};  // zero terminated
 +
 +void terminate_request_handler(int param) {
 +cout  \nReceived signal   param  , 
 +  intend to terminate soon, 
 +  repeat to force an immediate effect.\n;
 +terminating = true;
 +signal(param, prior_signal_handlers[param]);
 +}
 +
 +
  const int nowhere = -;

 +
  // parse message
  static void parse_message( const string msg, int *lat, int *lon ) {
 double dlat, dlon;
 @@ -281,8 +297,8 @@
 string::size_type pos = text.find( $GPGGA );
 if ( pos == string::npos )
 {
 -   *lat = -.0;
 -   *lon = -.0;
 +   *lat = nowhere;
 +   *lon = nowhere;
return;
 }
 string tmp = text.substr( pos + 7 );
 @@ -408,7 +424,8 @@

  void getWaitingTile() {
 while ( !waitingTiles.empty() ) {
 -   CompletedTiles::iterator ii = completedTiles.find(
 waitingTiles.front() );
 +   CompletedTiles::iterator ii =
 +completedTiles.find( waitingTiles.front() );
time_t now = time(0);
if ( ii == completedTiles.end() || ii-second + 600  now ) {
sync_tree(waitingTiles.front().c_str());
 @@ -422,7 +439,7 @@

  int main( int argc, char **argv ) {
 int port = 5501;
 -char host[256] = ;// accept messages from anyone
 +char host[256] = localhost;
 bool testing = false;
 bool do_checkout(true);
 int verbose(0);
 @@ -485,7 +502,6 @@

 // Must call this before any other net stuff
 netInit( argc,argv );
 -
 netSocket s;

 if ( ! s.open( false ) ) {  // open a UDP socket
 @@ -524,7 +540,14 @@
 }


 -while ( true ) {// main loop
 +for (int* sigp=termination_triggering_signals; *sigp; sigp++) {
 +prior_signal_handlers[*sigp] =
 +signal(*sigp, *terminate_request_handler);
 +if (verbose) cout  Intercepted signal   *sigp  endl;
 +}
 +
 +while ( !terminating ) {
 +// main loop
 recv_msg = false;
 if ( testing ) {
 // No FGFS communications
 @@ -532,6 +555,9 @@
 lon = -123;
 recv_msg = (lat != last_lat) || (lon != last_lon);
 } else {
 +if (verbose  waitingTiles.empty()) {
 +cout  Idle; waiting for FlightGear position\n;
 +}
 s.setBlocking(waitingTiles.empty());
 len = s.recv(msg, maxlen, 0);
 if (len = 0) {
 @@ -584,11 +610,11 @@
 }

else if ( testing ) {
 -   exit( 0 );
 +   terminating = true;
} else

 ulSleep( 1 );
 -} // while true
 +} // while !terminating

 return 0;
  }


 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Flightgear-devel mailing list
 Flightgear-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/flightgear-devel

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel