More work on resource monitor.
[egate.git] / kernel / eti.c
index 99e7370..f7a1b99 100644 (file)
@@ -2,7 +2,16 @@
  * Europagate, 1995
  *
  * $Log: eti.c,v $
- * Revision 1.8  1995/04/20 15:12:24  adam
+ * Revision 1.11  1995/05/01 16:26:56  adam
+ * More work on resource monitor.
+ *
+ * Revision 1.10  1995/05/01  12:43:29  adam
+ * First work on resource monitor program.
+ *
+ * Revision 1.9  1995/04/21  16:37:43  adam
+ * Parent (eti) creates BOTH FIFOs. dtbsun is more happy now.
+ *
+ * Revision 1.8  1995/04/20  15:12:24  adam
  * Minor hacks really.
  *
  * Revision 1.7  1995/04/19  16:01:57  adam
@@ -40,6 +49,9 @@
 #include <setjmp.h>
 #include <signal.h>
 
+#include <sys/file.h>
+#include <sys/stat.h>
+
 #include <gw-log.h>
 #include <gw-db.h>
 #include <gip.h>
@@ -76,6 +88,7 @@ static int email_header (struct str_queue *sq,
     return 1;
 }
 
+#if !USE_MONITOR
 static void start_kernel (int argc, char **argv, int id)
 {
     pid_t pid;
@@ -110,13 +123,13 @@ static void start_kernel (int argc, char **argv, int id)
        exit (1);
     }
 }
+#endif
 
-static void deliver (struct str_queue *sq, GIP gip)
+static void deliver (struct str_queue *sq, GIP gip, const char *msg)
 {
     int index = 0;
-    char *msg;
 
-    gip_wline (gip, "mail\n");
+    gip_wline (gip, msg);
     while ((msg = str_queue_get (sq, index++)))
         gip_wline (gip, msg);
     gip_wline (gip, "\001");
@@ -127,6 +140,7 @@ int main (int argc, char **argv)
     char from_str[LINE_MAX+1];
     char subject_str[LINE_MAX+1];
     char line_str[LINE_MAX+1];
+    char msg[20];
     GW_DB user_db;
     GIP  gip;
     void *user_info;
@@ -184,8 +198,13 @@ int main (int argc, char **argv)
         gw_log (GW_LOG_FATAL, module, "gw_db_lookup fail");
        exit (1);
     }
+#if USE_MONITOR
+    sprintf (fifo_server_name, "fifo.s");
+    sprintf (fifo_client_name, "fifo.c");
+#else
     sprintf (fifo_server_name, "fifo.s.%d", id);
     sprintf (fifo_client_name, "fifo.c.%d", id);
+#endif
 
     gip = gipc_initialize (fifo_client_name);
 
@@ -198,11 +217,19 @@ int main (int argc, char **argv)
         r = gipc_open (gip, fifo_server_name, 0);
     else if (pass == 2)
     {
+#if USE_MONITOR
+        gw_log (GW_LOG_FATAL, module, "Cannot contact monitor");
+       exit (1);
+#else
+#if 0
         gipc_close (gip);
         gipc_destroy (gip);
         unlink (fifo_server_name);
         unlink (fifo_client_name);
         gip = gipc_initialize (fifo_client_name);
+#endif
+
+       mknod (fifo_server_name, S_IFIFO|0666, 0);
         start_kernel (argc, argv, id);
         r = gipc_open (gip, fifo_server_name, 1);
     }
@@ -210,6 +237,7 @@ int main (int argc, char **argv)
     {
         gw_log (GW_LOG_FATAL, module, "Cannot start kernel");
        exit (1);
+#endif
     }
     if (r < 0)
         if (r == -2)
@@ -229,7 +257,12 @@ int main (int argc, char **argv)
        }
     /* deliver message ... */
     gw_log (GW_LOG_DEBUG, module, "Delivering mail");
-    deliver (queue, gip);
+#if USE_MONITOR
+    sprintf (msg, "eti %d\n", id);
+#else
+    strcpy (msg, "mail\n");
+#endif
+    deliver (queue, gip, msg);
     gw_log (GW_LOG_DEBUG, module, "Closing");
     gipc_close (gip);
     gipc_destroy (gip);