certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] certi/RTIG Federation.hh RTIG.cc RTIG.hh main.cc


From: certi-cvs
Subject: [certi-cvs] certi/RTIG Federation.hh RTIG.cc RTIG.hh main.cc
Date: Thu, 19 Jun 2008 13:57:00 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Mathé <jmm>    08/06/19 13:57:00

Modified files:
        RTIG           : Federation.hh RTIG.cc RTIG.hh main.cc 

Log message:
        RTIG.cc 
        Exit from RTIG :  For avoinding crash on exit after CTRl(C) action, 
include a watchdog within select function to check "terminate bool variable"

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/Federation.hh?cvsroot=certi&r1=3.49&r2=3.50
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/RTIG.cc?cvsroot=certi&r1=3.46&r2=3.47
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/RTIG.hh?cvsroot=certi&r1=3.28&r2=3.29
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/main.cc?cvsroot=certi&r1=3.16&r2=3.17

Patches:
Index: Federation.hh
===================================================================
RCS file: /sources/certi/certi/RTIG/Federation.hh,v
retrieving revision 3.49
retrieving revision 3.50
diff -u -b -r3.49 -r3.50
--- Federation.hh       11 Jun 2008 15:19:20 -0000      3.49
+++ Federation.hh       19 Jun 2008 13:56:59 -0000      3.50
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: Federation.hh,v 3.49 2008/06/11 15:19:20 rousse Exp $
+// $Id: Federation.hh,v 3.50 2008/06/19 13:56:59 jmm Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_RTIG_FEDERATION_HH
@@ -597,4 +597,4 @@
 
 #endif // _CERTI_RTIG_FEDERATION_HH
 
-// $Id: Federation.hh,v 3.49 2008/06/11 15:19:20 rousse Exp $
+// $Id: Federation.hh,v 3.50 2008/06/19 13:56:59 jmm Exp $

Index: RTIG.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/RTIG.cc,v
retrieving revision 3.46
retrieving revision 3.47
diff -u -b -r3.46 -r3.47
--- RTIG.cc     12 Jun 2008 07:39:51 -0000      3.46
+++ RTIG.cc     19 Jun 2008 13:56:59 -0000      3.47
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: RTIG.cc,v 3.46 2008/06/12 07:39:51 erk Exp $
+// $Id: RTIG.cc,v 3.47 2008/06/19 13:56:59 jmm Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -47,11 +47,13 @@
 static PrettyDebug D("RTIG", __FILE__);
 static PrettyDebug G("GENDOC",__FILE__);
 
+bool RTIG::terminate = false;
+
 // ----------------------------------------------------------------------------
 // Constructor
 // Note (JYR) : udpPort modified AFTER used in socketServer(.) call, strange...
 RTIG::RTIG()
-    : terminate(false), federationHandles(1),
+    :  federationHandles(1),
       socketServer(&tcpSocketServer, &udpSocketServer, udpPort),
       auditServer(RTIG_AUDIT_FILENAME),
       federations(socketServer, auditServer)
@@ -428,19 +430,37 @@
 
 while (!terminate) {
        // Initialize fd_set structure with all opened sockets.
+       #if WIN32
+
+       result = 0;     // Wait for an incoming message.
+       while (!result)
+               {
+               int test;
+               
        FD_ZERO(&fd);
        FD_SET(tcpSocketServer.returnSocket(), &fd);
 
-       #if WIN32
                 int highest_fd = socketServer.addToFDSet(&fd);
                 int server_socket = tcpSocketServer.returnSocket();
+
+               //typedef struct timeval {  long tv_sec;  long tv_usec; }       
 
+               timeval         watchDog;
+               watchDog.tv_sec= 0;
+               watchDog.tv_usec= 50000L;
+
                 highest_fd = server_socket>highest_fd ? server_socket : 
highest_fd;
                 
-                result = 0;    // Wait for an incoming message.
-                result = select(highest_fd+1, &fd, NULL, NULL, NULL);
+               result = select(highest_fd+1, &fd, NULL, NULL, &watchDog);
+               if (result < 0) test= WSAGetLastError();
+               if (terminate) break;
+               }
+       if (terminate) break;
                 
                 if((result == -1)&&(WSAGetLastError() == WSAEINTR)) break;
        #else
+               FD_ZERO(&fd);
+               FD_SET(tcpSocketServer.returnSocket(), &fd);
+
                int fd_max = socketServer.addToFDSet(&fd);
                fd_max = std::max(tcpSocketServer.returnSocket(), fd_max);
        
@@ -978,17 +998,17 @@
 
 // ----------------------------------------------------------------------------
 //! process received signals.
-void
+ void
 RTIG::signalHandler(int sig)
 {
 D.Out(pdError, "Received Signal %d.", sig);
 
 if (sig == SIGINT) terminate = true ;
-#ifndef WIN32
+#ifndef _WIN32
        if (sig == SIGPIPE) cout << "Ignoring 'Broken pipe' signal." << endl ;
 #endif
 }
 
 }} // namespace certi/rtig
 
-// $Id: RTIG.cc,v 3.46 2008/06/12 07:39:51 erk Exp $
+// $Id: RTIG.cc,v 3.47 2008/06/19 13:56:59 jmm Exp $

Index: RTIG.hh
===================================================================
RCS file: /sources/certi/certi/RTIG/RTIG.hh,v
retrieving revision 3.28
retrieving revision 3.29
diff -u -b -r3.28 -r3.29
--- RTIG.hh     30 May 2008 14:01:06 -0000      3.28
+++ RTIG.hh     19 Jun 2008 13:56:59 -0000      3.29
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: RTIG.hh,v 3.28 2008/05/30 14:01:06 erk Exp $
+// $Id: RTIG.hh,v 3.29 2008/06/19 13:56:59 jmm Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef CERTI_RTIG_HH
@@ -54,10 +54,12 @@
     RTIG();
     ~RTIG();
 
-    void signalHandler(int sig);
+    static void signalHandler(int sig);
+    static bool terminate ;
     void setVerbose(bool flag) { verbose = flag ; }
     void execute();
 
+
 private:
     // Both methods return the socket, because it may have been closed
     // & deleted.
@@ -118,7 +120,6 @@
 private:
     int tcpPort ;
     int udpPort ;
-    bool terminate ;
     bool verbose ;
     HandleManager<Handle> federationHandles ;
     SocketTCP tcpSocketServer ;
@@ -136,4 +137,4 @@
 
 #endif // CERTI_RTIG_HH
 
-// $Id: RTIG.hh,v 3.28 2008/05/30 14:01:06 erk Exp $
+// $Id: RTIG.hh,v 3.29 2008/06/19 13:56:59 jmm Exp $

Index: main.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/main.cc,v
retrieving revision 3.16
retrieving revision 3.17
diff -u -b -r3.16 -r3.17
--- main.cc     3 May 2008 18:34:18 -0000       3.16
+++ main.cc     19 Jun 2008 13:56:59 -0000      3.17
@@ -38,13 +38,11 @@
 using std::endl ;
 using std::string ;
 
-static RTIG myRTIG;
-
 // ----------------------------------------------------------------------------
 //! SignalHandler.
 extern "C" void SignalHandler(int sig)
 {
-    myRTIG.signalHandler(sig);
+    RTIG::signalHandler(sig);    
     // Catch signal again.
     std::signal(sig, SignalHandler);
 }
@@ -55,13 +53,14 @@
 NewHandler()
     throw (MemoryExhausted)
 {
-    throw MemoryExhausted("");
+    throw MemoryExhausted("main RTIG");
 }
 
 // ----------------------------------------------------------------------------
 //! RTIG server entry point.
 int main(int argc, char *argv[])
 {
+    RTIG myRTIG;
     gengetopt_args_info args ;
     if (cmdline_parser(argc, argv, &args)) exit(EXIT_FAILURE);
     bool verbose = args.verbose_flag ;
@@ -87,7 +86,7 @@
     }
 
     std::signal(SIGINT, SignalHandler);
-       #ifndef WIN32
+       #ifndef _WIN32
                std::signal(SIGPIPE, SignalHandler);
        #endif
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]