From 8186f9f009914b021fdc151d6e93fd3c8e17270b Mon Sep 17 00:00:00 2001 From: lericson Date: Sat, 9 Oct 2010 00:53:37 +0200 Subject: [PATCH] Always quit and free memcached result in gets --- _pylibmcmodule.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/_pylibmcmodule.c b/_pylibmcmodule.c index 16de85e..88f30d9 100644 --- a/_pylibmcmodule.c +++ b/_pylibmcmodule.c @@ -448,22 +448,22 @@ static PyObject *PylibMC_Client_gets(PylibMC_Client *self, PyObject *arg) { ret = _PylibMC_parse_memcached_value((char *)mc_val, val_size, flags); ret = Py_BuildValue("(NL)", ret, cas); - - /* reset cursor if mget for some reason returned more than one result. - this should be a no-op otherwise. */ - memcached_quit(self->mc); - - /* deallocate any indirect buffers, even though the struct itself - is on our stack */ - memcached_result_free(&results_obj); - - return ret; } else if (rc == MEMCACHED_END) { /* Key not found => (None, None) */ return Py_BuildValue("(OO)", Py_None, Py_None); } else { return PylibMC_ErrFromMemcached(self, "memcached_gets", rc); } + + /* reset cursor if mget for some reason returned more than one result. + this should be a no-op otherwise. */ + memcached_quit(self->mc); + + /* deallocate any indirect buffers, even though the struct itself + is on our stack */ + memcached_result_free(&results_obj); + + return ret; } /* {{{ Set commands (set, replace, add, prepend, append) */