X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=ae04ebefa921b37627b0fea6459686d7a43ca5b4;hb=54da2f13bc20e4369757453575668339c8dfd9fd;hp=9e48592ef41c6a1d403bd26d7d8fdca5f7f81301;hpb=896c0427df9d8eff5de6a1735dcd992e067df844;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 9e48592..ae04ebe 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.65 2002-08-02 19:26:55 adam Exp $ +/* $Id: zebraapi.c,v 1.69 2002-08-29 08:47:08 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -76,7 +76,7 @@ ZebraHandle zebra_open (ZebraService zs) return 0; zh = (ZebraHandle) xmalloc (sizeof(*zh)); - yaz_log (LOG_LOG, "zebra_open zs=%p returns %p", zs, zh); + yaz_log (LOG_DEBUG, "zebra_open zs=%p returns %p", zs, zh); zh->service = zs; zh->reg = 0; /* no register attached yet */ @@ -102,18 +102,17 @@ ZebraHandle zebra_open (ZebraService zs) default_encoding = res_get_def(zs->global_res, "encoding", "ISO-8859-1"); zh->record_encoding = xstrdup (default_encoding); -#if HAVE_ICONV_H + zh->iconv_to_utf8 = - iconv_open ("UTF-8", default_encoding); - if (zh->iconv_to_utf8 == (iconv_t)(-1)) + yaz_iconv_open ("UTF-8", default_encoding); + if (zh->iconv_to_utf8 == 0) yaz_log (LOG_WARN, "iconv: %s to UTF-8 unsupported", default_encoding); zh->iconv_from_utf8 = - iconv_open (default_encoding, "UTF-8"); - if (zh->iconv_to_utf8 == (iconv_t)(-1)) + yaz_iconv_open (default_encoding, "UTF-8"); + if (zh->iconv_to_utf8 == 0) yaz_log (LOG_WARN, "iconv: UTF-8 to %s unsupported", default_encoding); -#endif zebra_mutex_cond_lock (&zs->session_lock); @@ -131,13 +130,11 @@ ZebraService zebra_start (const char *configName) yaz_log (LOG_LOG, "zebra_start %s", configName); - if (!(res = res_open (configName, 0))) - yaz_log (LOG_WARN, "Cannot read resources `%s'", configName); - else + if ((res = res_open (configName, 0))) { ZebraService zh = xmalloc (sizeof(*zh)); - yaz_log (LOG_LOG, "Read resources `%s'", configName); + yaz_log (LOG_DEBUG, "Read resources `%s'", configName); zh->global_res = res; zh->configName = xstrdup(configName); @@ -182,7 +179,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name, assert (res); - yaz_log (LOG_LOG, "zebra_register_open rw = %d useshadow=%d p=%p", + yaz_log (LOG_DEBUG, "zebra_register_open rw = %d useshadow=%d p=%p", rw, useshadow, reg); reg->dh = data1_createx (DATA1_FLAG_XML); @@ -330,7 +327,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name, return 0; } reg->active = 2; - yaz_log (LOG_LOG, "zebra_register_open ok p=%p", reg); + yaz_log (LOG_DEBUG, "zebra_register_open ok p=%p", reg); return reg; } @@ -351,7 +348,7 @@ void zebra_admin_start (ZebraHandle zh) static void zebra_register_close (ZebraService zs, struct zebra_register *reg) { - yaz_log(LOG_LOG, "zebra_register_close p=%p", reg); + yaz_log(LOG_DEBUG, "zebra_register_close p=%p", reg); reg->stop_flag = 0; zebra_chdir (zs); if (reg->records) @@ -383,7 +380,7 @@ static void zebra_register_close (ZebraService zs, struct zebra_register *reg) xfree (reg->key_buf); xfree (reg->name); xfree (reg); - yaz_log (LOG_LOG, "zebra_register_close 2"); + yaz_log(LOG_DEBUG, "zebra_register_close 2"); } void zebra_stop(ZebraService zs) @@ -420,7 +417,7 @@ void zebra_close (ZebraHandle zh) return; zs = zh->service; - yaz_log (LOG_LOG, "zebra_close zh=%p", zh); + yaz_log (LOG_DEBUG, "zebra_close zh=%p", zh); if (!zh) return ; resultSetDestroy (zh, -1, 0, 0); @@ -431,12 +428,11 @@ void zebra_close (ZebraHandle zh) zebra_close_res (zh); xfree (zh->record_encoding); -#if HAVE_ICONV_H - if (zh->iconv_to_utf8 != (iconv_t) (-1)) - iconv_close (zh->iconv_to_utf8); - if (zh->iconv_from_utf8 != (iconv_t) (-1)) - iconv_close (zh->iconv_from_utf8); -#endif + + if (zh->iconv_to_utf8 != 0) + yaz_iconv_close (zh->iconv_to_utf8); + if (zh->iconv_from_utf8 != 0) + yaz_iconv_close (zh->iconv_from_utf8); xfree (zh->admin_databaseName); zebra_mutex_cond_lock (&zs->session_lock); @@ -694,6 +690,11 @@ int zebra_select_databases (ZebraHandle zh, int num_bases, zh->errCode = 109; return -1; } + if (!zh->lock_normal || !zh->lock_shadow) + { + zh->errCode = 2; + return -1; + } return 0; } @@ -1008,6 +1009,12 @@ int zebra_begin_read (ZebraHandle zh) zh->errCode = 109; return -1; } + if (!zh->lock_normal || !zh->lock_shadow) + { + (zh->trans_no)--; + zh->errCode = 2; + return -1; + } zebra_get_state (zh, &val, &seqno); if (val == 'd') val = 'o';