chiark / gitweb /
Move the plist file to examples/ along with the other startup files.
[disorder] / lib / trackdb.c
index eafcfc179ea879e0dac48b292f706389a8dd595f..5c64978e85f5de181d18acdb31b3b4549f290f6e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2005, 2006, 2007 Richard Kettlewell
+ * Copyright (C) 2005-2008 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -318,10 +318,18 @@ void trackdb_deinit(void) {
   if((err = trackdb_env->close(trackdb_env, 0)))
     fatal(0, "trackdb_env->close: %s", db_strerror(err));
 
-  if(rescan_pid != -1 && kill(rescan_pid, SIGTERM) < 0)
-    fatal(errno, "error killing rescanner");
+  if(rescan_pid != -1) {
+    /* shut down the rescanner */
+    if(kill(rescan_pid, SIGTERM) < 0)
+      fatal(errno, "error killing rescanner");
+    /* wait for the rescanner to finish */
+    while(waitpid(rescan_pid, &err, 0) == -1 && errno == EINTR)
+      ;
+  }
+
+  /* TODO kill any stats subprocesses */
 
-  /* terminate the deadlock manager */
+  /* finally terminate the deadlock manager */
   if(db_deadlock_pid != -1 && kill(db_deadlock_pid, SIGTERM) < 0)
     fatal(errno, "error killing deadlock manager");
   db_deadlock_pid = -1;
@@ -2160,7 +2168,7 @@ static int reap_rescan(ev_source attribute((unused)) *ev,
  * @param ev Event loop or 0 to block
  * @param check 1 to recheck lengths, 0 to suppress check
  */
-void trackdb_rescan(ev_source *ev, int check) {
+void trackdb_rescan(ev_source *ev, int recheck) {
   int w;
 
   if(rescan_pid != -1) {
@@ -2168,7 +2176,7 @@ void trackdb_rescan(ev_source *ev, int check) {
     return;
   }
   rescan_pid = subprogram(ev, -1, RESCAN,
-                          check ? "--check" : "--no-check",
+                          recheck ? "--check" : "--no-check",
                           (char *)0);
   if(ev) {
     ev_child(ev, rescan_pid, 0, reap_rescan, 0);
@@ -2604,7 +2612,7 @@ int trackdb_adduser(const char *user,
   WITH_TRANSACTION(create_user(user, password, rights, email, confirmation,
                                tid, DB_NOOVERWRITE));
   if(e) {
-    error(0, "cannot created user '%s' because they already exist", user);
+    error(0, "cannot create user '%s' because they already exist", user);
     return -1;
   } else {
     if(email)