[ruby-oci8-commit] [404] trunk/ruby-oci8/ext/oci8: * ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix memory leak when temporary
nobody at rubyforge.org
nobody at rubyforge.org
Sun Aug 15 01:12:33 EDT 2010
Revision: 404
Author: kubo
Date: 2010-08-15 01:12:32 -0400 (Sun, 15 Aug 2010)
Log Message:
-----------
* ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix memory leak when temporary
lobs are used.
Modified Paths:
--------------
branches/ruby-oci8-2.0/ChangeLog
branches/ruby-oci8-2.0/ext/oci8/apiwrap.yml
branches/ruby-oci8-2.0/ext/oci8/lob.c
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/ext/oci8/apiwrap.yml
trunk/ruby-oci8/ext/oci8/lob.c
Modified: branches/ruby-oci8-2.0/ChangeLog
===================================================================
--- branches/ruby-oci8-2.0/ChangeLog 2010-08-14 12:37:20 UTC (rev 403)
+++ branches/ruby-oci8-2.0/ChangeLog 2010-08-15 05:12:32 UTC (rev 404)
@@ -1,3 +1,7 @@
+2010-08-15 KUBO Takehiro <kubo at jiubao.org>
+ * ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix memory leak when temporary
+ lobs are used.
+
2010-08-14 KUBO Takehiro <kubo at jiubao.org>
* ext/oci8/bind.c: fix a bug that a string is bound to RAW.
Its encoding had been convertd to OCI.encoding incorrectly.
Modified: branches/ruby-oci8-2.0/ext/oci8/apiwrap.yml
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/apiwrap.yml 2010-08-14 12:37:20 UTC (rev 403)
+++ branches/ruby-oci8-2.0/ext/oci8/apiwrap.yml 2010-08-15 05:12:32 UTC (rev 404)
@@ -916,6 +916,13 @@
- OCIDuration duration
# round trip: 1
+OCILobFreeTemporary_nb:
+ :version: 810
+ :args: - OCISvcCtx *svchp
+ - OCIError *errhp
+ - OCILobLocator *locp
+
+# round trip: 1
OCILobGetChunkSize_nb:
:version: 810
:args: - OCISvcCtx *svchp
Modified: branches/ruby-oci8-2.0/ext/oci8/lob.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/lob.c 2010-08-14 12:37:20 UTC (rev 403)
+++ branches/ruby-oci8-2.0/ext/oci8/lob.c 2010-08-15 05:12:32 UTC (rev 404)
@@ -70,9 +70,27 @@
rb_gc_mark(lob->svc);
}
+static VALUE free_temp_lob(oci8_lob_t *lob)
+{
+ oci8_svcctx_t *svcctx = oci8_get_svcctx(lob->svc);
+
+ OCILobFreeTemporary_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob);
+ return Qnil;
+}
+
static void oci8_lob_free(oci8_base_t *base)
{
oci8_lob_t *lob = (oci8_lob_t *)base;
+ boolean is_temporary;
+
+ if (have_OCILobIsTemporary
+ && OCILobIsTemporary(oci8_envhp, oci8_errhp, lob->base.hp.lob, &is_temporary) == OCI_SUCCESS
+ && is_temporary) {
+ /* Exceptions in free_temp_lob() are ignored.
+ * oci8_lob_free() is called in GC. It must not raise an exception.
+ */
+ rb_rescue(free_temp_lob, (VALUE)base, NULL, 0);
+ }
lob->svc = Qnil;
}
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2010-08-14 12:37:20 UTC (rev 403)
+++ trunk/ruby-oci8/ChangeLog 2010-08-15 05:12:32 UTC (rev 404)
@@ -1,3 +1,7 @@
+2010-08-15 KUBO Takehiro <kubo at jiubao.org>
+ * ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix memory leak when temporary
+ lobs are used.
+
2010-06-15 KUBO Takehiro <kubo at jiubao.org>
* lib/oci8/metadata.rb: rename OCI8::Metadata::Column#type_string
to #data_type_string and add an alias from the former to the
Modified: trunk/ruby-oci8/ext/oci8/apiwrap.yml
===================================================================
--- trunk/ruby-oci8/ext/oci8/apiwrap.yml 2010-08-14 12:37:20 UTC (rev 403)
+++ trunk/ruby-oci8/ext/oci8/apiwrap.yml 2010-08-15 05:12:32 UTC (rev 404)
@@ -916,6 +916,13 @@
- OCIDuration duration
# round trip: 1
+OCILobFreeTemporary_nb:
+ :version: 810
+ :args: - OCISvcCtx *svchp
+ - OCIError *errhp
+ - OCILobLocator *locp
+
+# round trip: 1
OCILobGetChunkSize_nb:
:version: 810
:args: - OCISvcCtx *svchp
Modified: trunk/ruby-oci8/ext/oci8/lob.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/lob.c 2010-08-14 12:37:20 UTC (rev 403)
+++ trunk/ruby-oci8/ext/oci8/lob.c 2010-08-15 05:12:32 UTC (rev 404)
@@ -70,9 +70,27 @@
rb_gc_mark(lob->svc);
}
+static VALUE free_temp_lob(oci8_lob_t *lob)
+{
+ oci8_svcctx_t *svcctx = oci8_get_svcctx(lob->svc);
+
+ OCILobFreeTemporary_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob);
+ return Qnil;
+}
+
static void oci8_lob_free(oci8_base_t *base)
{
oci8_lob_t *lob = (oci8_lob_t *)base;
+ boolean is_temporary;
+
+ if (have_OCILobIsTemporary
+ && OCILobIsTemporary(oci8_envhp, oci8_errhp, lob->base.hp.lob, &is_temporary) == OCI_SUCCESS
+ && is_temporary) {
+ /* Exceptions in free_temp_lob() are ignored.
+ * oci8_lob_free() is called in GC. It must not raise an exception.
+ */
+ rb_rescue(free_temp_lob, (VALUE)base, NULL, 0);
+ }
lob->svc = Qnil;
}
More information about the ruby-oci8-commit
mailing list