]> andersk Git - moira.git/blobdiff - server/increment.pc
Allow hostname to start with a digit in hostname_check, but disallow it
[moira.git] / server / increment.pc
index 5b86c29b06776214f2c454b2895cc775344e6c2a..30a559e78c31962f0c865cc0cad4923a6f170a4d 100644 (file)
@@ -13,6 +13,7 @@
 #include "qrtn.h"
 
 #include <signal.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -70,8 +71,8 @@ void incremental_init(void)
 
   for (i = 0; i < MAXARGC; i++)
     {
-      before[i] = malloc(ARGLEN);
-      after[i] = malloc(ARGLEN);
+      before[i] = xmalloc(MAX_FIELD_WIDTH);
+      after[i] = xmalloc(MAX_FIELD_WIDTH);
     }
 }
 
@@ -103,7 +104,7 @@ void incremental_before(enum tables table, char *qual, char **argv)
       dosql(before);
       beforec = 2;
       break;
-    case CLUSTER_TABLE:
+    case CLUSTERS_TABLE:
       sprintf(stmt_buf, "SELECT c.name, c.description, c.location "
              "FROM clusters c WHERE %s", qual);
       dosql(before);
@@ -221,7 +222,7 @@ void incremental_after(enum tables table, char *qual, char **argv)
       dosql(after);
       afterc = 2;
       break;
-    case CLUSTER_TABLE:
+    case CLUSTERS_TABLE:
       sprintf(stmt_buf, "SELECT c.name, c.description, c.location "
              "FROM clusters c WHERE %s", qual);
       dosql(after);
@@ -310,7 +311,7 @@ void incremental_after(enum tables table, char *qual, char **argv)
       break;
     }
 
-  iu = malloc(sizeof(struct iupdate));
+  iu = xmalloc(sizeof(struct iupdate));
   iu->table = table_name[table];
   iu->beforec = beforec;
   iu->before = copy_argv(before, beforec);
@@ -342,7 +343,7 @@ void incremental_update(void)
   static struct inc_cache *cache;
   struct inc_cache *c;
   EXEC SQL BEGIN DECLARE SECTION;
-  char tab[17], serv[17];
+  char tab[INCREMENTAL_TABLE_NAME_SIZE], serv[INCREMENTAL_SERVICE_SIZE];
   EXEC SQL END DECLARE SECTION;
   struct iupdate *iu;
 
@@ -358,10 +359,10 @@ void incremental_update(void)
          EXEC SQL FETCH inc INTO :tab, :serv;
          if (sqlca.sqlcode)
            break;
-         c = malloc(sizeof(struct inc_cache));
+         c = xmalloc(sizeof(struct inc_cache));
          c->next = cache;
-         c->table = strdup(strtrim(tab));
-         c->service = strdup(strtrim(serv));
+         c->table = xstrdup(strtrim(tab));
+         c->service = xstrdup(strtrim(serv));
          cache = c;
        }
       EXEC SQL CLOSE inc;
@@ -376,18 +377,29 @@ void incremental_update(void)
            {
              iu->service = c->service;
              sq_save_data(incremental_exec, iu);
+             break;
            }
        }
+      if (!c)
+       {
+         free_argv(iu->before, iu->beforec);
+         free_argv(iu->after, iu->afterc);
+         free(iu);
+       }
     }
   if (inc_running == 0)
     next_incremental();
 }
 
+/* Pro*C 2.2.4 can't cope with the sigset_t below, at least in Solaris 2.6.
+   We add DEFINE=_PROC_ to the proc invocation and then #ifndef that around
+   this function so proc will pass it through without reading it. */
 
+#ifndef _PROC_
 void next_incremental(void)
 {
   struct iupdate *iu;
-  char *argv[MAXARGC * 2 + 4], cafter[3], cbefore[3], prog[BUFSIZ];
+  char *argv[MAXARGC * 2 + 4], cafter[3], cbefore[3], prog[MAXPATHLEN];
   int i;
   sigset_t sigs;
 
@@ -438,7 +450,7 @@ void next_incremental(void)
   free_argv(iu->after, iu->afterc);
   free(iu);
 }
-
+#endif
 
 /* Called when the current transaction is aborted to throw away any queued
  * incremental updates
@@ -461,9 +473,9 @@ void incremental_flush(void)
 
 char **copy_argv(char **argv, int argc)
 {
-  char **ret = malloc(sizeof(char *) * argc);
+  char **ret = xmalloc(sizeof(char *) * argc);
   while (--argc >= 0)
-    ret[argc] = strdup(strtrim(argv[argc]));
+    ret[argc] = xstrdup(strtrim(argv[argc]));
   return ret;
 }
 
This page took 0.040126 seconds and 4 git commands to generate.