X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-c.c;fp=src%2Fzoom-c.c;h=28eb79820e754efa502f978772b2da8aa8c8c998;hp=b1874eac46ead33cc14090fd2d153cca52463c98;hb=dd016baf50d8cd02a1a32d1fd10b5544cae6ff96;hpb=9779edc6c34338368c661ef6105dcde1a7398b95 diff --git a/src/zoom-c.c b/src/zoom-c.c index b1874ea..28eb798 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -298,9 +298,7 @@ ZOOM_API(ZOOM_connection) c->cookies = 0; c->saveAPDU_wrbuf = 0; -#if HAVE_LIBMEMCACHED_MEMCACHED_H - c->mc_st = 0; -#endif + ZOOM_memcached_init(c); return c; } @@ -545,29 +543,11 @@ ZOOM_API(void) yaz_cookies_destroy(c->cookies); c->cookies = yaz_cookies_create(); -#if HAVE_LIBMEMCACHED_MEMCACHED_H - if (c->mc_st) + if (ZOOM_memcached_configure(c)) { - memcached_free(c->mc_st); - c->mc_st = 0; - } -#endif - val = ZOOM_options_get(c->options, "memcached"); - if (val && *val) - { -#if HAVE_LIBMEMCACHED_MEMCACHED_H - c->mc_st = memcached(val, strlen(val)); - if (!c->mc_st) - { - ZOOM_set_error(c, ZOOM_ERROR_MEMCACHED, val); - return; - } -#else - ZOOM_set_error(c, ZOOM_ERROR_MEMCACHED, "not enabled"); + ZOOM_connection_remove_tasks(c); return; -#endif } - if (c->sru_mode == zoom_sru_error) { ZOOM_set_error(c, ZOOM_ERROR_UNSUPPORTED_PROTOCOL, val); @@ -613,10 +593,7 @@ ZOOM_API(void) return; yaz_log(c->log_api, "%p ZOOM_connection_destroy", c); -#if HAVE_LIBMEMCACHED_MEMCACHED_H - if (c->mc_st) - memcached_free(c->mc_st); -#endif + ZOOM_memcached_destroy(c); if (c->cs) cs_close(c->cs); @@ -774,23 +751,7 @@ ZOOM_API(ZOOM_resultset) r->next = c->resultsets; c->resultsets = r; -#if HAVE_LIBMEMCACHED_MEMCACHED_H - r->mc_key = wrbuf_alloc(); - wrbuf_puts(r->mc_key, "0;"); - wrbuf_puts(r->mc_key, c->host_port); - wrbuf_puts(r->mc_key, ";"); - if (c->user) - wrbuf_puts(r->mc_key, c->user); - wrbuf_puts(r->mc_key, ";"); - if (c->group) - wrbuf_puts(r->mc_key, c->group); - wrbuf_puts(r->mc_key, ";"); - if (c->password) - wrbuf_sha1_puts(r->mc_key, c->password, 1); - wrbuf_puts(r->mc_key, ";"); - wrbuf_sha1_puts(r->mc_key, ZOOM_query_get_query_string(q), 1); - wrbuf_puts(r->mc_key, ";"); -#endif + ZOOM_memcached_resultset(r, q); if (c->host_port && c->proto == PROTO_HTTP) {