[PATCH] ruby: make sure the database is closed
authorFelipe Contreras <felipe.contreras@gmail.com>
Mon, 23 Apr 2012 12:48:20 +0000 (15:48 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:40 +0000 (09:46 -0800)
82/f9fe11fce2e5a7d9d5063b91f87f2510c16b72 [new file with mode: 0644]

diff --git a/82/f9fe11fce2e5a7d9d5063b91f87f2510c16b72 b/82/f9fe11fce2e5a7d9d5063b91f87f2510c16b72
new file mode 100644 (file)
index 0000000..154fadb
--- /dev/null
@@ -0,0 +1,95 @@
+Return-Path: <felipe.contreras@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7FC8D431FD9\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 05:48:51 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=unavailable\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id boAjadw5OIhC for <notmuch@notmuchmail.org>;\r
+       Mon, 23 Apr 2012 05:48:51 -0700 (PDT)\r
+Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com\r
+       [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 52804431FD7\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 05:48:50 -0700 (PDT)\r
+Received: by lahc1 with SMTP id c1so9220121lah.26\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 05:48:48 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer;\r
+       bh=kc5BhnESDswK35XfDdPa6FZJZbNEf/JduoaUlcRarmk=;\r
+       b=bYRx1WlKPd7gZqeKEGb5kN8+Mh0ay0D8FdokJQRwBorvqyi3Bs3omTOug5caA/QvIu\r
+       DL+N8l/8Q980ctT7XesGL+gobNfXIf9odx+1xZCbp/+ZWQLPB4/QSfV6LIJh0rutv7Qr\r
+       My2qNJ/2V1b0WeOXMtTllvY2gxA6S5ophER2BBj5XgoXekPX+cF0vZez+WGIHJyX57mF\r
+       77BGtHGdmgX4CG5zb8iGWmfDMpF+HcmgW5uHqDHilUzhiMVJzaMJ6Vos8NBPUY+9b3ZZ\r
+       f93cIIhlq01bo+oSCw+T8kUCmtdCZKBt9LuHHk4ZDwDYtgFR50aXOgQNW7ALOu+sleWY\r
+       40YQ==\r
+Received: by 10.112.36.66 with SMTP id o2mr7298904lbj.107.1335185328583;\r
+       Mon, 23 Apr 2012 05:48:48 -0700 (PDT)\r
+Received: from localhost (81-197-42-53.elisa-mobile.fi. [81.197.42.53])\r
+       by mx.google.com with ESMTPS id ox7sm19776217lbb.17.2012.04.23.05.48.47\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 23 Apr 2012 05:48:47 -0700 (PDT)\r
+From: Felipe Contreras <felipe.contreras@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] ruby: make sure the database is closed\r
+Date: Mon, 23 Apr 2012 15:48:20 +0300\r
+Message-Id: <1335185300-12950-1-git-send-email-felipe.contreras@gmail.com>\r
+X-Mailer: git-send-email 1.7.10\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 23 Apr 2012 12:48:51 -0000\r
+\r
+If the Ruby code does not manually close the database, we need to make\r
+sure it's closed when garbage collected.\r
+\r
+In Ruby, users are not _required_ to close, the garbage collector should\r
+take care of that.\r
+\r
+Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\r
+---\r
+ bindings/ruby/database.c |    8 +++++++-\r
+ 1 file changed, 7 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c\r
+index 982fd59..7b2ed47 100644\r
+--- a/bindings/ruby/database.c\r
++++ b/bindings/ruby/database.c\r
+@@ -20,10 +20,16 @@\r
\r
+ #include "defs.h"\r
\r
++static void\r
++database_free (void *p)\r
++{\r
++    notmuch_database_close (p);\r
++}\r
++\r
+ VALUE\r
+ notmuch_rb_database_alloc (VALUE klass)\r
+ {\r
+-    return Data_Wrap_Struct (klass, NULL, NULL, NULL);\r
++    return Data_Wrap_Struct (klass, NULL, database_free, NULL);\r
+ }\r
\r
+ /*\r
+-- \r
+1.7.10\r
+\r