unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] ruby: make sure the database is closed
@ 2012-04-23 12:43 Felipe Contreras
  2012-04-23 14:04 ` Ali Polatel
  0 siblings, 1 reply; 11+ messages in thread
From: Felipe Contreras @ 2012-04-23 12:43 UTC (permalink / raw)
  To: notmuch; +Cc: Ali Polatel

If the Ruby code does not manually close the database, we need to make
sure it's closed when garbage collected.

In Ruby, users are not _required_ to close, the garbage collector should
take care of that.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 bindings/ruby/database.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c
index 982fd59..7b2ed47 100644
--- a/bindings/ruby/database.c
+++ b/bindings/ruby/database.c
@@ -20,10 +20,16 @@
 
 #include "defs.h"
 
+static void
+database_free (void *p)
+{
+    notmuch_database_close (p);
+}
+
 VALUE
 notmuch_rb_database_alloc (VALUE klass)
 {
-    return Data_Wrap_Struct (klass, NULL, NULL, NULL);
+    return Data_Wrap_Struct (klass, NULL, database_free, NULL);
 }
 
 /*
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [PATCH] ruby: make sure the database is closed
@ 2012-04-23 12:48 Felipe Contreras
  0 siblings, 0 replies; 11+ messages in thread
From: Felipe Contreras @ 2012-04-23 12:48 UTC (permalink / raw)
  To: notmuch

If the Ruby code does not manually close the database, we need to make
sure it's closed when garbage collected.

In Ruby, users are not _required_ to close, the garbage collector should
take care of that.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 bindings/ruby/database.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c
index 982fd59..7b2ed47 100644
--- a/bindings/ruby/database.c
+++ b/bindings/ruby/database.c
@@ -20,10 +20,16 @@
 
 #include "defs.h"
 
+static void
+database_free (void *p)
+{
+    notmuch_database_close (p);
+}
+
 VALUE
 notmuch_rb_database_alloc (VALUE klass)
 {
-    return Data_Wrap_Struct (klass, NULL, NULL, NULL);
+    return Data_Wrap_Struct (klass, NULL, database_free, NULL);
 }
 
 /*
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-04-25 20:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-23 12:43 [PATCH] ruby: make sure the database is closed Felipe Contreras
2012-04-23 14:04 ` Ali Polatel
2012-04-23 15:07   ` Felipe Contreras
2012-04-23 20:43     ` Ali Polatel
2012-04-23 22:45       ` Felipe Contreras
2012-04-23 23:46         ` Ali Polatel
2012-04-24  0:45           ` Felipe Contreras
2012-04-24  1:15             ` Austin Clements
2012-04-24 10:30               ` Felipe Contreras
2012-04-25 20:22                 ` Ali Polatel
  -- strict thread matches above, loose matches on Subject: below --
2012-04-23 12:48 Felipe Contreras

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).