sks-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH]: fix cursor leak (was: [Sks-devel] Improving the SKS development


From: Kim Minh Kaplan
Subject: [PATCH]: fix cursor leak (was: [Sks-devel] Improving the SKS development model)
Date: Sun, 30 Aug 2009 08:28:30 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

There is a cursor leak in keydb.ml.  Attached patch fixes it.  It is
available in my repository (http://www.kim-minh.com/hg/sks/) as
d351d05877dc.

Kim Minh.

# HG changeset patch
# User Kim Minh Kaplan <address@hidden>
# Date 1251618169 -7200
# Node ID d351d05877dca577dce3463675dc9e4e44f973ea
# Parent  c67b2f226c24d2a1a2be3f804a5ae842588a292f
BUGFIX: do not leak the joined cursor in Keydb.get_by_words.

diff -r c67b2f226c24 -r d351d05877dc keydb.ml
--- a/keydb.ml  Thu Aug 13 06:49:00 2009 +0200
+++ b/keydb.ml  Sun Aug 30 09:42:49 2009 +0200
@@ -539,8 +539,11 @@
        let lengths = List.map ~f:Cursor.count cursors in
        if MList.min lengths > max_internal_matches
        then raise (Invalid_argument "Insufficiently specific words");
-       let cj = Cursor.join dbs.key cursors [] in
-       let keystrings = jcursor_get_all ~max cj in
+       let keystrings =
+         let cj = Cursor.join dbs.key cursors [] in
+         protect ~f:(fun () -> jcursor_get_all ~max cj)
+           ~finally:(fun () -> Cursor.close cj)
+       in
        if List.length keystrings >= max then
          raise (Invalid_argument "Too many responses")
        else

reply via email to

[Prev in Thread] Current Thread [Next in Thread]