Fix the way we delete the shadow files after a "succesful" commit
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 4 Apr 2006 00:00:18 +0000 (00:00 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 4 Apr 2006 00:00:18 +0000 (00:00 +0000)
operation. The problem with the exising code was that read-only
sessions (searches, etc) could "suddenly" miss the shadow files that
they read..

index/zebraapi.c

index b3258e3..0c94394 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebraapi.c,v 1.210 2006-03-31 15:58:04 adam Exp $
+/* $Id: zebraapi.c,v 1.211 2006-04-04 00:00:18 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -754,8 +754,6 @@ static void zebra_select_register (ZebraHandle zh, const char *new_reg)
     {
        if (res_get_int(zh->res, "staticrank", &zh->m_staticrank) == ZEBRA_OK)
            yaz_log(YLOG_LOG, "static rank set and is %d", zh->m_staticrank);
     {
        if (res_get_int(zh->res, "staticrank", &zh->m_staticrank) == ZEBRA_OK)
            yaz_log(YLOG_LOG, "static rank set and is %d", zh->m_staticrank);
-       else
-           yaz_log(YLOG_LOG, "static rank unset");
     }
 }
 
     }
 }
 
@@ -1988,19 +1986,24 @@ static ZEBRA_RES zebra_commit_ex(ZebraHandle zh, int clean_only)
             sync ();
 #endif
         }
             sync ();
 #endif
         }
-        yaz_log (YLOG_DEBUG, "commit clean");
-        bf_commitClean (bfs, rval);
         seqno++;
         zebra_set_state (zh, 'o', seqno);
         seqno++;
         zebra_set_state (zh, 'o', seqno);
+
+       zebra_unlock (zh->lock_shadow);
+       zebra_unlock (zh->lock_normal);
+
+       zebra_lock_w(zh->lock_shadow);
+        bf_commitClean (bfs, rval);
+       zebra_unlock (zh->lock_normal);
     }
     else
     {
     }
     else
     {
+       zebra_unlock(zh->lock_shadow);
+       zebra_unlock(zh->lock_normal);
         yaz_log (log_level, "nothing to commit");
     }
     bfs_destroy (bfs);
 
         yaz_log (log_level, "nothing to commit");
     }
     bfs_destroy (bfs);
 
-    zebra_unlock (zh->lock_shadow);
-    zebra_unlock (zh->lock_normal);
     return ZEBRA_OK;
 }
 
     return ZEBRA_OK;
 }