[1988] in Moira Commits

home help back first fref pref prev next nref lref last post

/svn/moira r4127 - in trunk/moira: . afssync db incremental incremental/incr-runner server util util/bsd-compat

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Mon Aug 5 08:54:47 2013

Date: Mon, 5 Aug 2013 08:54:39 -0400
From: Garry Zacheiss <zacheiss@MIT.EDU>
Message-Id: <201308051254.r75CsdjZ019781@drugstore.mit.edu>
To: moira-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: zacheiss
Date: 2013-08-05 08:54:39 -0400 (Mon, 05 Aug 2013)
New Revision: 4127

Added:
   trunk/moira/incremental/incr-runner/
   trunk/moira/incremental/incr-runner/Makefile.in
   trunk/moira/incremental/incr-runner/incr-runner.pc
   trunk/moira/incremental/incr-runner/startincr.c
   trunk/moira/util/bsd-compat/
   trunk/moira/util/bsd-compat/Makefile.in
   trunk/moira/util/bsd-compat/setproctitle.c
   trunk/moira/util/bsd-compat/setproctitle.h
   trunk/moira/util/bsd-compat/vis.c
   trunk/moira/util/bsd-compat/vis.h
Removed:
   trunk/moira/afssync/vis.c
   trunk/moira/afssync/vis.h
Modified:
   trunk/moira/Makefile.in
   trunk/moira/afssync/Makefile.in
   trunk/moira/configure
   trunk/moira/configure.in
   trunk/moira/db/dbopt.sql
   trunk/moira/db/schema.sql
   trunk/moira/incremental/Makefile.in
   trunk/moira/server/Makefile.in
   trunk/moira/server/increment.pc
   trunk/moira/server/mr_main.c
   trunk/moira/server/mr_server.h
   trunk/moira/server/qsupport.pc
   trunk/moira/server/queries2.c
Log:
Rototill incremental processing.

Modified: trunk/moira/Makefile.in
===================================================================
--- trunk/moira/Makefile.in	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/Makefile.in	2013-08-05 12:54:39 UTC (rev 4127)
@@ -14,7 +14,7 @@
 libdir=@libdir@
 
 CLIENTDIRS=include lib clients update man @WEBMOIRA_SUBDIRS@
-SVRDIRS=db server backup dbck dcm gen regtape incremental @AFS_SYNCDIR@ @RSAREF_SUBDIRS@
+SVRDIRS=db util/bsd-compat server backup dbck dcm gen regtape incremental @AFS_SYNCDIR@ @RSAREF_SUBDIRS@
 DEPDIRS=@COM_ERR_SUBDIR@
 
 SUBDIRS=$(CLIENTDIRS) @SVRSUBDIRS@

Modified: trunk/moira/afssync/Makefile.in
===================================================================
--- trunk/moira/afssync/Makefile.in	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/afssync/Makefile.in	2013-08-05 12:54:39 UTC (rev 4127)
@@ -32,8 +32,12 @@
 BUILDTOP=..
 mrbindir=@mrbindir@
 
+BSDCOMPAT_PROC_INCLUDE=INCLUDE=$(SRCTOP)/util/bsd-compat
+BSDCOMPAT_INCLUDE=-I$(SRCTOP)/util/bsd-compat
+BSDCOMPAT_LIB=$(BUILDTOP)/util/bsd-compat/bsdcompat.a
+
 SYNC_OBJS=sync.lo ptutils.lo utils.lo ubik.lo
-UTIL_OBJS=pt_util.lo ptutils.lo utils.lo ubik.lo vis.lo
+UTIL_OBJS=pt_util.lo ptutils.lo utils.lo ubik.lo
 
 CFILES=sync.c
 
@@ -42,10 +46,10 @@
 .SUFFIXES: .pc .lo
 
 .pc.c:
-	$(PRO_C) $(PRO_C_FLAGS) INAME=$< ONAME=$@
+	$(PRO_C) $(PRO_C_FLAGS) $(BSDCOMPAT_PROC_INCLUDE) INAME=$< ONAME=$@
 
 .c.lo:
-	$(LIBTOOL) --mode=compile $(CC) -c $(ALL_CFLAGS) $<
+	$(LIBTOOL) --mode=compile $(CC) -c $(ALL_CFLAGS) $(BSDCOMPAT_INCLUDE) $<
 
 all: $(TARGET)
 
@@ -65,5 +69,5 @@
 afssync: $(SYNC_OBJS) $(MR_LIBDEP)
 	$(LIBTOOL) --mode=link $(CC) -static -o $@ $(LDFLAGS) $(SYNC_OBJS) $(SQL_LIBS) $(LIBS) $(AFS_LIBS) -llwp -lprot -lcom_err -lafsutil
 
-pt_util: $(UTIL_OBJS) $(MR_LIBDEP)
-	$(LIBTOOL) --mode=link $(CC) -static -o $@ $(LDFLAGS) $(UTIL_OBJS) $(LIBS) $(AFS_LIBS) -llwp -lprot -lcom_err -lafsutil
+pt_util: $(UTIL_OBJS) $(MR_LIBDEP) $(BSDCOMPAT_LIB)
+	$(LIBTOOL) --mode=link $(CC) -static -o $@ $(LDFLAGS) $(UTIL_OBJS) $(LIBS) $(AFS_LIBS) $(BSDCOMPAT_LIB) -llwp -lprot -lcom_err -lafsutil

Modified: trunk/moira/configure
===================================================================
--- trunk/moira/configure	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/configure	2013-08-05 12:54:39 UTC (rev 4127)
@@ -20285,7 +20285,7 @@
 	    ;;
     esac
     SVRSUBDIRS='$(SVRDIRS)'
-    SERVER_OUTPUT_FILES="db/Makefile server/Makefile backup/Makefile dbck/Makefile dcm/Makefile gen/Makefile incremental/Makefile incremental/mailman/Makefile incremental/route-server/Makefile reg_svr/Makefile regtape/Makefile"
+    SERVER_OUTPUT_FILES="db/Makefile server/Makefile backup/Makefile dbck/Makefile dcm/Makefile gen/Makefile incremental/Makefile incremental/incr-runner/Makefile incremental/mailman/Makefile incremental/route-server/Makefile reg_svr/Makefile regtape/Makefile util/bsd-compat/Makefile"
     PRO_C=$oracle/bin/proc
     PRO_C_OPTS=CODE=ANSI_C
     PRO_C_DEFS="DEFINE=_PROC_ $PRO_C_DEFS"
@@ -21030,7 +21030,8 @@
 
 
 
-for ac_func in strlcpy strlcat uname strvis
+
+for ac_func in strlcpy strlcat uname strvis setproctitle
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5

Modified: trunk/moira/configure.in
===================================================================
--- trunk/moira/configure.in	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/configure.in	2013-08-05 12:54:39 UTC (rev 4127)
@@ -303,7 +303,7 @@
 	    ;;
     esac
     SVRSUBDIRS='$(SVRDIRS)'
-    SERVER_OUTPUT_FILES="db/Makefile server/Makefile backup/Makefile dbck/Makefile dcm/Makefile gen/Makefile incremental/Makefile incremental/mailman/Makefile incremental/route-server/Makefile reg_svr/Makefile regtape/Makefile"
+    SERVER_OUTPUT_FILES="db/Makefile server/Makefile backup/Makefile dbck/Makefile dcm/Makefile gen/Makefile incremental/Makefile incremental/incr-runner/Makefile incremental/mailman/Makefile incremental/route-server/Makefile reg_svr/Makefile regtape/Makefile util/bsd-compat/Makefile"
     PRO_C=$oracle/bin/proc
     PRO_C_OPTS=CODE=ANSI_C
     PRO_C_DEFS="DEFINE=_PROC_ $PRO_C_DEFS"
@@ -469,7 +469,7 @@
 AC_SUBST(CURSES_SUBDIRS)
 
 
-AC_CHECK_FUNCS(strlcpy strlcat uname strvis)
+AC_CHECK_FUNCS(strlcpy strlcat uname strvis setproctitle)
 
 AC_CHECK_FUNC(sigaction, AC_DEFINE(HAVE_POSIX_SIGNALS))
 

Modified: trunk/moira/db/dbopt.sql
===================================================================
--- trunk/moira/db/dbopt.sql	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/db/dbopt.sql	2013-08-05 12:54:39 UTC (rev 4127)
@@ -96,3 +96,5 @@
 
 create index i_hwaddrmap_machid on hwaddrmap (mach_id);
 create index i_hwaddrmap_hwaddr on hwaddrmap (hwaddr);
+
+create sequence incremental_seq increment by 1 start with 1 minvalue 1 maxvalue 2147483648 cycle nocache;
\ No newline at end of file

Modified: trunk/moira/db/schema.sql
===================================================================
--- trunk/moira/db/schema.sql	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/db/schema.sql	2013-08-05 12:54:39 UTC (rev 4127)
@@ -497,3 +497,16 @@
 	mach_id		INTEGER		DEFAULT 0	NOT NULL,
 	hwaddr		VARCHAR(12)	DEFAULT CHR(0)	NOT NULL
 );
+
+create table incremental_queue
+(
+	table_name      VARCHAR(16)     DEFAULT CHR(0)  NOT NULL,
+	service         VARCHAR(16)     DEFAULT CHR(0)  NOT NULL,
+	beforec		INTEGER		DEFAUlT 0	NOT NULL,
+	afterc		INTEGER		DEFAULT 0	NOT NULL,
+	before		VARCHAR(4000)	DEFAULT CHR(0)	NOT NULL,
+	after		VARCHAR(4000)	DEFAULT CHR(0)	NOT NULL,
+	timestamp	DATE		DEFAULT SYSDATE	NOT NULL,
+	incremental_id	INTEGER		DEFAULT 0	NOT NULL
+);
+	

Modified: trunk/moira/incremental/Makefile.in
===================================================================
--- trunk/moira/incremental/Makefile.in	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/incremental/Makefile.in	2013-08-05 12:54:39 UTC (rev 4127)
@@ -19,7 +19,7 @@
 BUILDTOP=..
 mrbindir=@mrbindir@
 
-SUBDIRS=@AFS_SUBDIRS@ @WINAD_SUBDIRS@ @KERBEROS_SUBDIRS@ route-server
+SUBDIRS=incr-runner @AFS_SUBDIRS@ @WINAD_SUBDIRS@ @KERBEROS_SUBDIRS@ route-server
 
 .SUFFIXES: .pc
 

Modified: trunk/moira/server/Makefile.in
===================================================================
--- trunk/moira/server/Makefile.in	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/server/Makefile.in	2013-08-05 12:54:39 UTC (rev 4127)
@@ -30,6 +30,9 @@
 mrlibdir=@mrlibdir@
 libdir=@mrlibdir@
 
+BSDCOMPAT_PROC_INCLUDE=INCLUDE=$(SRCTOP)/util/bsd-compat
+BSDCOMPAT_INCLUDE=-I$(SRCTOP)/util/bsd-compat
+BSDCOMPAT_LIB=$(BUILDTOP)/util/bsd-compat/bsdcompat.a
 
 SERVER_OBJS=	mr_main.lo mr_sauth.lo mr_scall.lo mr_shutdown.lo mr_util.lo \
 		qvalidate.lo qaccess.lo qsetup.lo qsupport.lo qfollow.lo \
@@ -45,10 +48,10 @@
 .SUFFIXES: .pc .lo
 
 .pc.c:
-	$(PRO_C) $(PRO_C_FLAGS) INAME=$< ONAME=$@
+	$(PRO_C) $(PRO_C_FLAGS) $(BSDCOMPAT_PROC_INCLUDE) INAME=$< ONAME=$@
 
 .c.lo:
-	$(LIBTOOL) --mode=compile $(CC) -c $(ALL_CFLAGS) $<
+	$(LIBTOOL) --mode=compile $(CC) -c $(ALL_CFLAGS) $(BSDCOMPAT_INCLUDE) $<
 
 all: $(TARGET)
 
@@ -64,8 +67,8 @@
 	$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) moirad $(DESTDIR)$(mrbindir)
 	$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) startmoira $(DESTDIR)$(mrbindir)
 
-moirad: $(SERVER_OBJS) $(SCHEMA_OBJS) $(MR_LIBDEP)
-	$(LIBTOOL) --mode=link $(CC) -static -o $@ $(LDFLAGS) $(SERVER_OBJS) $(SCHEMA_OBJS) $(SQL_LIBS) $(LIBS)
+moirad: $(SERVER_OBJS) $(SCHEMA_OBJS) $(MR_LIBDEP) $(BSDCOMPAT_LIB)
+	$(LIBTOOL) --mode=link $(CC) -static -o $@ $(LDFLAGS) $(SERVER_OBJS) $(SCHEMA_OBJS) $(SQL_LIBS) $(LIBS) $(BSDCOMPAT_LIB)
 
 startmoira: $(START_OBJS)
 	$(LIBTOOL) --mode=link $(CC) -static -o $@ $(LDFLAGS) $(START_OBJS) $(LIBS)

Modified: trunk/moira/server/increment.pc
===================================================================
--- trunk/moira/server/increment.pc	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/server/increment.pc	2013-08-05 12:54:39 UTC (rev 4127)
@@ -1,4 +1,4 @@
-/* $Id$
+/* $id: increment.pc 4110 2013-05-09 15:43:17Z zacheiss $
  *
  * Deal with incremental updates
  *
@@ -11,6 +11,7 @@
 #include "mr_server.h"
 #include "query.h"
 #include "qrtn.h"
+#include "vis.h"
 
 #include <signal.h>
 #include <stdio.h>
@@ -27,10 +28,6 @@
 extern char *table_name[];
 extern int num_tables;
 
-int inc_pid = 0;
-int inc_running = 0;
-time_t inc_started;
-
 #define MAXARGC 20
 
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
@@ -48,7 +45,6 @@
 
 /* structures to save entire sets of incremental changes */
 struct save_queue *incremental_sq = NULL;
-struct save_queue *incremental_exec = NULL;
 struct iupdate {
   char *table;
   int beforec;
@@ -58,7 +54,6 @@
   char *service;
 };
 
-void next_incremental(void);
 char **copy_argv(char **argv, int argc);
 void free_argv(char **argv, int argc);
 int table_num(char *table);
@@ -69,8 +64,6 @@
 
   if (!incremental_sq)
     incremental_sq = sq_create();
-  if (!incremental_exec)
-    incremental_exec = sq_create();
 
   for (i = 0; i < MAXARGC; i++)
     {
@@ -566,7 +559,10 @@
   EXEC SQL BEGIN DECLARE SECTION;
   char tab[INCREMENTAL_TABLE_NAME_SIZE], serv[INCREMENTAL_SERVICE_SIZE];
   EXEC SQL END DECLARE SECTION;
-  struct iupdate *iu, *iu_save;
+  struct iupdate *iu;
+  void *before_flattened = NULL, *after_flattened = NULL;
+  char *before_encoded = NULL, *after_encoded = NULL;
+  int i, length = 0;
 
   if (!inited)
     {
@@ -597,16 +593,68 @@
 	  if (!strcmp(c->table, iu->table))
 	    {
 	      iu->service = c->service;
-	      iu_save = xmalloc(sizeof(struct iupdate));
-	      iu_save->service = iu->service;
-	      iu_save->table = iu->table;
-	      iu_save->beforec = iu->beforec;
-	      iu_save->afterc = iu->afterc;
-	      iu_save->before = copy_argv(iu->before, iu->beforec);
-	      iu_save->after = copy_argv(iu->after, iu->afterc);
-	      sq_save_data(incremental_exec, iu_save);
+
+	      /* Flatten argvs */
+	      if (iu->beforec > 0)
+		{
+		  before_flattened = xmalloc(iu->beforec * MAX_FIELD_WIDTH);
+		  length = 0;
+
+		  for (i = 0; i < iu->beforec; i++)
+		    {
+		      memcpy(before_flattened + length, iu->before[i], strlen(iu->before[i]) + 1);
+		      length += strlen(iu->before[i]) + 1;
+		    }
+		  
+		  before_encoded = xmalloc(4 * iu->beforec * MAX_FIELD_WIDTH + 1);
+		  strvisx(before_encoded, before_flattened, length, VIS_CSTYLE);
+		}
+	      
+	      if (iu->afterc > 0)
+		{
+		  after_flattened = xmalloc(iu->afterc * MAX_FIELD_WIDTH);
+		  length = 0;
+		  
+		  for (i = 0; i < iu->afterc; i++)
+		    {
+		      memcpy(after_flattened + length, iu->after[i], strlen(iu->after[i]) + 1);
+		      length += strlen(iu->after[i]) + 1;
+		    }
+		  
+		  after_encoded = xmalloc(4 * iu->afterc * MAX_FIELD_WIDTH + 1);
+		  strvisx(after_encoded, after_flattened, length, VIS_CSTYLE);
+		}
+	      
+	      /* Stick into DB */
+	      EXEC SQL INSERT INTO incremental_queue
+		(incremental_id, table_name, service, beforec, afterc, before, after, timestamp)
+		VALUES (incremental_seq.nextval, :iu->table, :iu->service, :iu->beforec, :iu->afterc, 
+			NVL(:before_encoded, CHR(0)), NVL(:after_encoded, CHR(0)), SYSDATE);
+	      EXEC SQL COMMIT WORK;
+
+	      if (before_flattened)
+		{
+		  free(before_flattened);
+		  before_flattened = NULL;
+		}
+	      if (before_encoded)
+		{
+		  free(before_encoded);
+		  before_encoded = NULL;
+		}
+	      if (after_flattened)
+		{
+		  free(after_flattened);
+		  after_flattened = NULL;
+		}
+	      if (after_encoded)
+		{
+		  free(after_encoded);
+		  after_encoded = NULL;
+		}
 	    }
 	}
+
       if (!c)
 	{
 	  free_argv(iu->before, iu->beforec);
@@ -614,71 +662,8 @@
 	  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[MAXPATHLEN];
-  int i;
-  sigset_t sigs;
-
-  if (!incremental_exec)
-    incremental_init();
-
-  if (sq_empty(incremental_exec) ||
-      (inc_running && now - inc_started < INC_TIMEOUT))
-    return;
-
-  if (inc_running)
-    critical_alert(whoami, "moirad", "incremental timeout on pid %d", inc_pid);
-
-  sq_remove_data(incremental_exec, &iu);
-  argv[1] = iu->table;
-  sprintf(cbefore, "%d", iu->beforec);
-  argv[2] = cbefore;
-  sprintf(cafter, "%d", iu->afterc);
-  argv[3] = cafter;
-  for (i = 0; i < iu->beforec; i++)
-    argv[4 + i] = iu->before[i];
-  for (i = 0; i < iu->afterc; i++)
-    argv[4 + iu->beforec + i] = iu->after[i];
-
-  sprintf(prog, "%s/%s.incr", BIN_DIR, iu->service);
-  argv[0] = prog;
-  argv[4 + iu->beforec + iu->afterc] = 0;
-
-  sigemptyset(&sigs);
-  sigaddset(&sigs, SIGCHLD);
-  sigprocmask(SIG_BLOCK, &sigs, NULL);
-  inc_pid = vfork();
-  switch (inc_pid)
-    {
-    case 0:
-      execv(prog, argv);
-      _exit(1);
-    case -1:
-      critical_alert(whoami, "moirad", "Failed to start incremental update %s", prog);
-      break;
-    default:
-      inc_running = 1;
-      inc_started = now;
-    }
-  sigprocmask(SIG_UNBLOCK, &sigs, NULL);
-
-  free_argv(iu->before, iu->beforec);
-  free_argv(iu->after, iu->afterc);
-  free(iu);
-}
-#endif
-
 /* Called when the current transaction is aborted to throw away any queued
  * incremental updates
  */

Modified: trunk/moira/server/mr_main.c
===================================================================
--- trunk/moira/server/mr_main.c	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/server/mr_main.c	2013-08-05 12:54:39 UTC (rev 4127)
@@ -223,8 +223,6 @@
 	{
 	  if (errno != EINTR)
 	    com_err(whoami, errno, "in select");
-	  if (!inc_running || now - inc_started > INC_TIMEOUT)
-	    next_incremental();
 	  continue;
 	}
 
@@ -239,8 +237,6 @@
 	}
 
       time(&now);
-      if (!inc_running || now - inc_started > INC_TIMEOUT)
-	next_incremental();
       tardy = now - 30 * 60;
 
       /* If we're asleep and we should wake up, do it */
@@ -393,8 +389,6 @@
 
   while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
     {
-      if (pid == inc_pid)
-	inc_running = 0;
       if (!takedown && (WTERMSIG(status) != 0 || WEXITSTATUS(status) != 0))
 	{
 	  child_exited_abnormally = 1;

Modified: trunk/moira/server/mr_server.h
===================================================================
--- trunk/moira/server/mr_server.h	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/server/mr_server.h	2013-08-05 12:54:39 UTC (rev 4127)
@@ -59,7 +59,7 @@
 extern char *krb_realm;
 
 /* max length of query argument allowed */
-#define ARGLEN	257
+#define ARGLEN	MAX_FIELD_WIDTH
 /* Used to setup static argv, maximum argc */
 #define QMAXARGS	30
 
@@ -92,7 +92,6 @@
 
 /* prototypes from increment.dc */
 void incremental_init(void);
-void next_incremental(void);
 void incremental_update(void);
 void incremental_flush(void);
 
@@ -308,6 +307,9 @@
 int get_subcontainers_of_container(struct query *q, char **argv, client *cl,
 			    int (*action)(int, char *[], void *),
 			    void *actarg);
+int get_incremental_queue_length(struct query *q, char **argv, client *cl,
+				 int (*action)(int, char *[], void *),
+				 void *actarg);
 
 /* prototypes from qvalidate.pc */
 int validate_fields(struct query *q, char *argv[], struct valobj *vo, int n);

Modified: trunk/moira/server/qsupport.pc
===================================================================
--- trunk/moira/server/qsupport.pc	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/server/qsupport.pc	2013-08-05 12:54:39 UTC (rev 4127)
@@ -2485,3 +2485,37 @@
 
   return MR_SUCCESS;
 }
+
+int get_incremental_queue_length(struct query *q, char *argv[], client *cl,
+				 int (*action)(int, char *[], void *), void *actarg)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  char service[INCREMENTAL_SERVICE_SIZE];
+  int count = 0;
+  EXEC SQL END DECLARE SECTION;
+  char *rargv[2], countbuf[5];
+
+  rargv[0] = service;
+  rargv[1] = countbuf;
+  EXEC SQL DECLARE svc_csr CURSOR FOR
+    SELECT DISTINCT service FROM incremental;
+  if (dbms_errno)
+    return mr_errcode;
+  EXEC SQL OPEN svc_csr;
+  if (dbms_errno)
+    return mr_errcode;
+  while (1)
+    {
+      EXEC SQL FETCH svc_csr INTO :service;
+      if (sqlca.sqlcode)
+	break;
+      strcpy(service, strtrim(service));
+      EXEC SQL SELECT COUNT(*) INTO :count FROM incremental_queue
+	WHERE service = :service;
+      sprintf(countbuf, "%d", count);
+      (*action)(2, rargv, actarg);
+    }
+  EXEC SQL CLOSE svc_csr;
+  
+  return MR_SUCCESS;
+}

Modified: trunk/moira/server/queries2.c
===================================================================
--- trunk/moira/server/queries2.c	2013-07-29 12:40:52 UTC (rev 4126)
+++ trunk/moira/server/queries2.c	2013-08-05 12:54:39 UTC (rev 4127)
@@ -4389,6 +4389,22 @@
   "containername", "listname",
 };
 
+static struct validate giql_validate = {
+  0,
+  0,
+  0,
+  0,
+  0,
+  0,
+  0,
+  0,
+  get_incremental_queue_length
+};
+
+static char *giql_fields[] = {
+  "service", "length",
+};
+
 /* Generalized Query Definitions */
 
 /* Multiple versions of the same query MUST be listed in ascending
@@ -8949,6 +8965,23 @@
     &glic_validate,
   },
 
+  {
+    /* Q_GIQL - GET_INCREMENTAL_QUEUE_LENGTH */
+    "get_incremental_queue_length",
+    "giql",
+    2,
+    MR_Q_RETRIEVE,
+    0,
+    0,
+    0,
+    giql_fields,
+    2,
+    0,
+    0,
+    NULL,
+    &giql_validate,
+  },
+
 };
 
 int QueryCount = (sizeof(Queries) / sizeof(struct query));


home help back first fref pref prev next nref lref last post