All pastes #411147 Raw Edit

emcsvr.cc.patch

public text v1 · immutable
#411147 ·published 2007-03-26 21:31 UTC
rendered paste body
--- emcsvr.cc.old	2007-03-26 17:17:32.000000000 -0400
+++ emcsvr.cc	2007-03-26 17:17:28.000000000 -0400
@@ -96,6 +96,7 @@
 main (int argc, char *argv[])
 {
   double start_time;
+  int s;
 
   // process command line args
   if (0 != emcGetArgs (argc, argv))
@@ -111,101 +112,77 @@
   rcs_print ("after iniLoad()\n");
 
 
-  start_time = etime ();
+  start_time = etime () + MAX_TIME;
 
-  while (fabs (etime () - start_time) < 10.0 &&
-	 (emcCommandChannel == NULL || emcStatusChannel == NULL
-	  || toolCommandChannel == NULL || toolStatusChannel == NULL
-	  || emcErrorChannel == NULL))
+  emcCommandChannel =
+    new RCS_CMD_CHANNEL (emcFormat, "emcCommand", "emcsvr", EMC_NMLFILE);
+  emcStatusChannel =
+    new RCS_STAT_CHANNEL (emcFormat, "emcStatus", "emcsvr", EMC_NMLFILE);
+  emcErrorChannel =
+    new NML (nmlErrorFormat, "emcError", "emcsvr", EMC_NMLFILE);
+  toolCommandChannel =
+    new RCS_CMD_CHANNEL (emcFormat, "toolCmd", "emcsvr", EMC_NMLFILE);
+  toolStatusChannel =
+    new RCS_STAT_CHANNEL (emcFormat, "toolSts", "emcsvr", EMC_NMLFILE);
+
+
+  //reinstantiation loop
+  while (etime () < start_time && !s)
     {
-      if (NULL == emcCommandChannel)
+      s = 1;
+      if (!emcCommandChannel->valid ())
 	{
-	  rcs_print ("emcCommandChannel==NULL, attempt to create\n");
+	  delete emcCommandChannel;
 	  emcCommandChannel =
 	    new RCS_CMD_CHANNEL (emcFormat, "emcCommand", "emcsvr",
 				 EMC_NMLFILE);
+	  s = 0;
 	}
-      if (NULL == emcStatusChannel)
+      if (!emcStatusChannel->valid ())
 	{
-	  rcs_print ("emcStatusChannel==NULL, attempt to create\n");
+	  rcs_print
+	    ("emcStatusChannel bungalo-ed, attempt to reinstantiate\n");
+	  delete emcStatusChannel;
 	  emcStatusChannel =
 	    new RCS_STAT_CHANNEL (emcFormat, "emcStatus", "emcsvr",
 				  EMC_NMLFILE);
+	  s = 0;
 	}
-      if (NULL == emcErrorChannel)
+      if (!emcErrorChannel->valid ())
 	{
+	  rcs_print
+	    ("emcErrorChannel bungalo-ed, attempt to reinstantiate\n");
+	  delete emcErrorChannel;
 	  emcErrorChannel =
 	    new NML (nmlErrorFormat, "emcError", "emcsvr", EMC_NMLFILE);
+	  s = 0;
 	}
-      if (NULL == toolCommandChannel)
-	{
-	  toolCommandChannel =
-	    new RCS_CMD_CHANNEL (emcFormat, "toolCmd", "emcsvr", EMC_NMLFILE);
-	}
-      if (NULL == toolStatusChannel)
-	{
-	  toolStatusChannel =
-	    new RCS_STAT_CHANNEL (emcFormat, "toolSts", "emcsvr",
-				  EMC_NMLFILE);
-	}
-
 
-      if (!emcCommandChannel->valid ())
-	{
-	  delete emcCommandChannel;
-	  emcCommandChannel = NULL;
-	}
-      if (!emcStatusChannel->valid ())
-	{
-	  delete emcStatusChannel;
-	  emcStatusChannel = NULL;
-	}
-      if (!emcErrorChannel->valid ())
-	{
-	  delete emcErrorChannel;
-	  emcErrorChannel = NULL;
-	}
       if (!toolCommandChannel->valid ())
 	{
+	  rcs_print
+	    ("toolCommandChannel bungalo-ed, attempt to reinstantiate\n");
 	  delete toolCommandChannel;
-	  toolCommandChannel = NULL;
+	  toolCommandChannel =
+	    new RCS_CMD_CHANNEL (emcFormat, "toolCmd", "emcsvr", EMC_NMLFILE);
+	  s = 0;
 	}
       if (!toolStatusChannel->valid ())
 	{
+	  rcs_print
+	    ("toolStatusChannel bungalo-ed, attempt to reinstantiate\n");
 	  delete toolStatusChannel;
-	  toolStatusChannel = NULL;
+	  toolStatusChannel =
+	    new RCS_STAT_CHANNEL (emcFormat, "toolSts", "emcsvr",
+				  EMC_NMLFILE);
+	  s = 0;
 	}
-
-      esleep (0.200);
+      esleep (RETRY_DELAY);
     }
 
   set_rcs_print_destination (RCS_PRINT_TO_STDERR);
 
-  if (NULL == emcCommandChannel)
-    {
-      emcCommandChannel =
-	new RCS_CMD_CHANNEL (emcFormat, "emcCommand", "emcsvr", EMC_NMLFILE);
-    }
-  if (NULL == emcStatusChannel)
-    {
-      emcStatusChannel =
-	new RCS_STAT_CHANNEL (emcFormat, "emcStatus", "emcsvr", EMC_NMLFILE);
-    }
-  if (NULL == emcErrorChannel)
-    {
-      emcErrorChannel =
-	new NML (nmlErrorFormat, "emcError", "emcsvr", EMC_NMLFILE);
-    }
-  if (NULL == toolCommandChannel)
-    {
-      toolCommandChannel =
-	new RCS_CMD_CHANNEL (emcFormat, "toolCmd", "emcsvr", EMC_NMLFILE);
-    }
-  if (NULL == toolStatusChannel)
-    {
-      toolStatusChannel =
-	new RCS_STAT_CHANNEL (emcFormat, "toolSts", "emcsvr", EMC_NMLFILE);
-    }
+
 
   signal (SIGTERM, nice_exit);