From: Adam Dickmeiss Date: Tue, 20 May 2003 21:39:57 +0000 (+0000) Subject: Handle non-existant register area better X-Git-Tag: ZEBRA.1.3.12~55 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=af396a0ed07e6455e01d463d88771b76f40f257c;p=idzebra-moved-to-github.git Handle non-existant register area better --- diff --git a/index/main.c b/index/main.c index c721067..cf2546d 100644 --- a/index/main.c +++ b/index/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.103 2003-03-25 19:56:01 adam Exp $ +/* $Id: main.c,v 1.104 2003-05-20 21:39:57 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -205,9 +205,9 @@ int main (int argc, char **argv) if (!trans_started) { trans_started=1; - zebra_begin_trans (zh, 1); + if (zebra_begin_trans (zh, 1)) + exit(1); } - switch (cmd) { case 'u': diff --git a/index/zebraapi.c b/index/zebraapi.c index b3c650f..9e81dbe 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.101 2003-05-20 13:52:41 adam Exp $ +/* $Id: zebraapi.c,v 1.102 2003-05-20 21:39:57 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -1040,7 +1040,8 @@ void zebra_create_database (ZebraHandle zh, const char *database) if (zebra_select_database (zh, database)) return; - zebra_begin_trans (zh, 1); + if (zebra_begin_trans (zh, 1)) + return; zs = zh->service; /* announce database */ @@ -1128,6 +1129,7 @@ void zebra_end_read (ZebraHandle zh) int zebra_begin_trans (ZebraHandle zh, int rw) { + yaz_log(LOG_LOG, "zebra_begin_trans rw=%d trans=%d", rw, zh->trans_no); if (!zh->res) { zh->errCode = 2; @@ -1159,8 +1161,6 @@ int zebra_begin_trans (ZebraHandle zh, int rw) zh->errCode=0; - yaz_log (LOG_LOG, "zebra_begin_trans"); - zh->records_inserted = 0; zh->records_updated = 0; zh->records_deleted = 0; @@ -1225,6 +1225,21 @@ int zebra_begin_trans (ZebraHandle zh, int rw) zh->path_reg); if (zh->reg) zh->reg->seqno = seqno; + else + { + zebra_set_state (zh, 'o', seqno); + + zebra_unlock (zh->lock_shadow); + zebra_unlock (zh->lock_normal); + + zh->trans_no--; + zh->trans_w_no = 0; + + zh->errCode = 2; + zh->errString = "zebra_begin_trans: cannot open register"; + yaz_log(LOG_FATAL, zh->errString); + return -1; + } } else { @@ -1288,6 +1303,9 @@ int zebra_begin_trans (ZebraHandle zh, int rw) zh->res, zh->path_reg); if (!zh->reg) { + zebra_unlock (zh->lock_normal); + zebra_unlock (zh->lock_shadow); + zh->trans_no--; zh->errCode = 109; return -1; }