static int afterc;
/* structures to save entire sets of incremental changes */
-struct save_queue *incremental_sq;
+struct save_queue *incremental_sq = NULL;
struct iupdate {
char *table;
int beforec;
aarg12 = after[12];
aarg13 = after[13];
aarg14 = after[14];
- incremental_sq = sq_create();
+ if (incremental_sq == NULL)
+ incremental_sq = sq_create();
}
}
-/* THIS IS WRONG. We should keep a table of services getting incremental
- * updates. But for now, just assume AFS
+/* Actually start incremental updates. This caches the update table
+ * the first time it is called.
*/
+struct inc_cache {
+ struct inc_cache *next;
+ char *table;
+ char *service;
+};
+
+
invoke_updates(argv, argc)
char **argv;
int argc;
-{
+##{
+ static int inited = 0;
+ static struct inc_cache *cache;
+ struct inc_cache *c;
+## char tab[17], serv[17];
int pid, i;
- char *prog;
-
- prog = "/u1/sms/bin/afs.incr";
- argv[0] = prog;
- argv[argc] = 0;
- pid = vfork();
- switch (pid) {
- case 0:
- for (i = getdtablesize() - 1; i > 2; i--)
- close(i);
- execv(prog, argv);
- exit(1);
- case -1:
- com_err(whoami, 0, "Failed to start incremental update");
- return;
- default:
- return;
+ char prog[64];
+
+ if (!inited) {
+ inited++;
+
+## retrieve (tab = incremental.table, serv = incremental.service) {
+ c = (struct inc_cache *)malloc(sizeof(struct inc_cache));
+ c->next = cache;
+ c->table = strsave(tab);
+ c->service = strsave(serv);
+ cache = c;
+## }
}
-}
+
+ for (c = cache; c; c = c->next) {
+ if (!strcmp(c->table, argv[1])) {
+ sprintf(prog, "/u1/sms/bin/%s.incr", c->table);
+ argv[0] = prog;
+ argv[argc] = 0;
+ pid = vfork();
+ switch (pid) {
+ case 0:
+ for (i = getdtablesize() - 1; i > 2; i--)
+ close(i);
+ execv(prog, argv);
+ exit(1);
+ case -1:
+ com_err(whoami, 0, "Failed to start incremental update");
+ return;
+ default:
+ return;
+ }
+ }
+ }
+##}
/* Called when the current transaction is aborted to throw away any queued