Fixed bug regarding online updates on WIN32.
[idzebra-moved-to-github.git] / index / zebraapi.c
index 0b79bc8..a2c2d55 100644 (file)
@@ -3,7 +3,14 @@
  * All rights reserved.
  *
  * $Log: zebraapi.c,v $
- * Revision 1.39  2000-11-29 14:24:01  adam
+ * Revision 1.41  2000-12-01 17:59:08  adam
+ * Fixed bug regarding online updates on WIN32.
+ * When zebra.cfg is not available the server will not abort.
+ *
+ * Revision 1.40  2000/11/29 15:21:31  adam
+ * Fixed problem with passwd db.
+ *
+ * Revision 1.39  2000/11/29 14:24:01  adam
  * Script configure uses yaz pthreads options. Added locking for
  * zebra_register_{lock,unlock}.
  *
@@ -211,8 +218,12 @@ static int zebra_register_lock (ZebraHandle zh, int rw)
        logf (LOG_LOG, "Register in read/write mode");
     else if (zh->service->registerState == state)
     {
+        logf (LOG_LOG, "registerChange = %ld lastChange = %ld",
+            (long) zh->service->registerChange, (long)lastChange);
        if (zh->service->registerChange >= lastChange)
+        {
            return 0;
+        }
        logf (LOG_LOG, "Register completely updated since last access");
     }
     else if (zh->service->registerState == -1)
@@ -294,11 +305,22 @@ ZebraService zebra_start (const char *configName)
     if (!(zh->res = res_open (zh->configName)))
     {
        logf (LOG_WARN, "Failed to read resources `%s'", zh->configName);
-       return zh;
+//     return zh;
     }
     zebra_chdir (zh);
     zebra_server_lock_init (zh);
     zebra_mutex_cond_init (&zh->session_lock);
+    if (!res_get (zh->res, "passwd"))
+       zh->passwd_db = NULL;
+    else
+    {
+       zh->passwd_db = passwd_db_open ();
+       if (!zh->passwd_db)
+           logf (LOG_WARN|LOG_ERRNO, "passwd_db_open failed");
+       else
+           passwd_db_file (zh->passwd_db, res_get (zh->res, "passwd"));
+    }
+
     return zh;
 }
 
@@ -345,17 +367,6 @@ static int zebra_register_activate (ZebraService zh, int rw)
     
     zebraRankInstall (zh, rank1_class);
 
-    if (!res_get (zh->res, "passwd"))
-       zh->passwd_db = NULL;
-    else
-    {
-       zh->passwd_db = passwd_db_open ();
-       if (!zh->passwd_db)
-           logf (LOG_WARN|LOG_ERRNO, "passwd_db_open failed");
-       else
-           passwd_db_file (zh->passwd_db, res_get (zh->res, "passwd"));
-    }
-
     if (!(zh->records = rec_open (zh->bfs, rw, 0)))
     {
        logf (LOG_WARN, "rec_open");
@@ -492,7 +503,11 @@ void zebra_stop(ZebraService zs)
        return ;
     yaz_log (LOG_LOG, "zebra_stop");
 
-    assert (!zs->sessions);
+    zebra_mutex_cond_lock (&zs->session_lock);
+    while (zs->sessions)
+        zebra_close (zs->sessions);
+
+    zebra_mutex_cond_unlock (&zs->session_lock);
 
     zebra_mutex_cond_destroy (&zs->session_lock);