System call sync(2) used after update/commit.
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 12 Dec 1995 16:00:54 +0000 (16:00 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 12 Dec 1995 16:00:54 +0000 (16:00 +0000)
Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
and F_RDLCK.

index/extract.c
index/lockidx.c
index/lockutil.c
index/main.c

index 5c1f738..b320cbc 100644 (file)
@@ -4,7 +4,12 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: extract.c,v $
- * Revision 1.43  1995-12-11 09:12:46  adam
+ * Revision 1.44  1995-12-12 16:00:54  adam
+ * System call sync(2) used after update/commit.
+ * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
+ * and F_RDLCK.
+ *
+ * Revision 1.43  1995/12/11  09:12:46  adam
  * The rec_get function returns NULL if record doesn't exist - will
  * happen in the server if the result set records have been deleted since
  * the creation of the set (i.e. the search).
@@ -184,7 +189,6 @@ void key_open (int mem)
 {
     if (mem < 50000)
         mem = 50000;
-    logf (LOG_LOG, "key_open %d", mem);
     key_buf = xmalloc (mem);
     ptr_top = mem/sizeof(char*);
     ptr_i = 0;
@@ -311,7 +315,6 @@ void key_flush (void)
 int key_close (void)
 {
     key_flush ();
-    logf (LOG_LOG, "buf free");
     xfree (key_buf);
     rec_close (&records);
     dict_close (matchDict);
index c04bd89..eb833b2 100644 (file)
@@ -4,7 +4,12 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: lockidx.c,v $
- * Revision 1.3  1995-12-11 11:43:29  adam
+ * Revision 1.4  1995-12-12 16:00:57  adam
+ * System call sync(2) used after update/commit.
+ * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
+ * and F_RDLCK.
+ *
+ * Revision 1.3  1995/12/11  11:43:29  adam
  * Locking based on fcntl instead of flock.
  * Setting commitEnable removed. Command line option -n can be used to
  * prevent commit if commit setting is defined in the configuration file.
@@ -134,11 +139,17 @@ void zebraIndexLock (int commitNow)
     sprintf (path, "%s%s", pathPrefix, FNAME_MAIN_LOCK);
     while (1)
     {
-        lock_fd = open (path, O_CREAT|O_RDWR|O_EXCL|O_SYNC, 0666);
+        lock_fd = open (path, O_CREAT|O_RDWR|O_EXCL, 0666);
         if (lock_fd == -1)
         {
             lock_fd = open (path, O_RDONLY);
-            assert (lock_fd != -1);
+            if (lock_fd == -1) 
+            {
+                if (errno == ENOENT)
+                    continue;
+                logf (LOG_FATAL|LOG_ERRNO, "open %s", path);
+                exit (1);
+            }
             if (zebraLockNB (lock_fd, 1) == -1)
             {
                 if (errno == EWOULDBLOCK)
index 79dd0dc..d626d70 100644 (file)
@@ -4,7 +4,12 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: lockutil.c,v $
- * Revision 1.2  1995-12-11 11:43:29  adam
+ * Revision 1.3  1995-12-12 16:00:57  adam
+ * System call sync(2) used after update/commit.
+ * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
+ * and F_RDLCK.
+ *
+ * Revision 1.2  1995/12/11  11:43:29  adam
  * Locking based on fcntl instead of flock.
  * Setting commitEnable removed. Command line option -n can be used to
  * prevent commit if commit setting is defined in the configuration file.
@@ -48,12 +53,20 @@ static int intLock (int fd, int type, int cmd)
 
 int zebraLock (int fd, int wr)
 {
+#if 1
+    return intLock (fd, wr ? F_EXLCK : F_SHLCK, F_SETLKW);
+#else
     return intLock (fd, wr ? F_WRLCK : F_RDLCK, F_SETLKW);
+#endif
 }
 
 int zebraLockNB (int fd, int wr)
 {
-    return intLock (fd, wr ? F_WRLCK : F_RDLCK, F_SETLK);
+#if 1
+    return intLock (fd, wr ? F_EXLCK : F_SHLCK, F_SETLKW);
+#else
+    return intLock (fd, wr ? F_WRLCK : F_RDLCK, F_SETLKW);
+#endif
 }
 
 int zebraUnlock (int fd)
index a3fb510..553e280 100644 (file)
@@ -4,7 +4,12 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: main.c,v $
- * Revision 1.29  1995-12-11 11:43:30  adam
+ * Revision 1.30  1995-12-12 16:00:59  adam
+ * System call sync(2) used after update/commit.
+ * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
+ * and F_RDLCK.
+ *
+ * Revision 1.29  1995/12/11  11:43:30  adam
  * Locking based on fcntl instead of flock.
  * Setting commitEnable removed. Command line option -n can be used to
  * prevent commit if commit setting is defined in the configuration file.
@@ -148,6 +153,7 @@ int main (int argc, char **argv)
         " update <dir>  Update index with files below <dir>.\n"
        "               If <dir> is empty filenames are read from stdin.\n"
         " delete <dir>  Delete index with files below <dir>.\n"
+        " commit        Commit changes\n"
         "Options:\n"
        " -t <type>     Index files as <type> (grs or text).\n"
        " -c <config>   Read configuration file <config>.\n"
@@ -201,6 +207,7 @@ int main (int argc, char **argv)
                         zebraIndexWait (1);
                         logf (LOG_LOG, "Commit execute");
                         bf_commitExec ();
+                        sync ();
                         zebraIndexLockMsg ("d");
                         zebraIndexWait (0);
                         logf (LOG_LOG, "Commit clean");
@@ -212,12 +219,6 @@ int main (int argc, char **argv)
                 else if (!strcmp (arg, "stat") || !strcmp (arg, "status"))
                 {
                     zebraIndexLock (0);
-                    bf_cache (0);
-                    rec_prstat ();
-                }
-                else if (!strcmp (arg, "cstat") || !strcmp (arg, "cstatus"))
-                {
-                    zebraIndexLock (1);
                     rval = res_get (common_resource, "commit");
                     if (rval && *rval)
                     {
@@ -270,6 +271,7 @@ int main (int argc, char **argv)
                     logf (LOG_LOG, "Merging with index");
                     key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, nsections,
                                60);
+                    sync ();
                 }
             }
         }