[ruby-oci8-commit] [558] trunk/ruby-oci8: fix segmentation fault when the process exits on rubinius.

nobody at rubyforge.org nobody at rubyforge.org
Sun Mar 3 05:34:26 UTC 2013


Revision: 558
Author:   kubo
Date:     2013-03-03 05:34:24 +0000 (Sun, 03 Mar 2013)
Log Message:
-----------
fix segmentation fault when the process exits on rubinius.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/oci8.c

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2013-03-02 12:02:11 UTC (rev 557)
+++ trunk/ruby-oci8/ChangeLog	2013-03-03 05:34:24 UTC (rev 558)
@@ -1,3 +1,7 @@
+2013-03-03  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/oci8.c: fix segmentation fault when the process
+	    exits on rubinius.
+
 2013-03-02  KUBO Takehiro  <kubo at jiubao.org>
 	* .yardopts, ext/oci8/object.c, lib/oci8/metadata.rb,
 	  lib/oci8/oracle_version.rb: update comments for rdoc/yard.

Modified: trunk/ruby-oci8/ext/oci8/oci8.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.c	2013-03-02 12:02:11 UTC (rev 557)
+++ trunk/ruby-oci8/ext/oci8/oci8.c	2013-03-03 05:34:24 UTC (rev 558)
@@ -38,6 +38,8 @@
 static VALUE cOCI8;
 static VALUE cSession;
 static VALUE cServer;
+static VALUE cEnvironment;
+static VALUE cProcess;
 static ID id_at_session_handle;
 static ID id_at_server_handle;
 
@@ -48,7 +50,7 @@
 
     if (self == obj) {
         oci8_base_t *base;
-        obj = rb_obj_alloc(oci8_cOCIHandle);
+        obj = rb_obj_alloc(cEnvironment);
         base = DATA_PTR(obj);
         base->type = OCI_HTYPE_ENV;
         base->hp.ptr = oci8_envhp;
@@ -61,21 +63,16 @@
     return rb_apply(obj, SYM2ID(method_id), args);
 }
 
-typedef struct oci8_svcctx_associate {
-    oci8_base_t base;
-    oci8_svcctx_t *svcctx;
-} oci8_svcctx_associate_t;
-
-static void oci8_svcctx_associate_free(oci8_base_t *base)
+static void oci8_dont_free_handle_free(oci8_base_t *base)
 {
     base->type = 0;
     base->hp.ptr = NULL;
 }
 
-static oci8_base_vtable_t oci8_svcctx_associate_vtable = {
+static oci8_base_vtable_t oci8_dont_free_handle_vtable = {
     NULL,
-    oci8_svcctx_associate_free,
-    sizeof(oci8_svcctx_associate_t),
+    oci8_dont_free_handle_free,
+    sizeof(oci8_base_t),
 };
 
 static void copy_session_handle(oci8_svcctx_t *svcctx)
@@ -1124,8 +1121,10 @@
     cOCI8 = rb_define_class("OCI8", oci8_cOCIHandle);
 #endif
     cOCI8 = oci8_define_class("OCI8", &oci8_svcctx_vtable);
-    cSession = oci8_define_class_under(cOCI8, "Session", &oci8_svcctx_associate_vtable);
-    cServer = oci8_define_class_under(cOCI8, "Server", &oci8_svcctx_associate_vtable);
+    cSession = oci8_define_class_under(cOCI8, "Session", &oci8_dont_free_handle_vtable);
+    cServer = oci8_define_class_under(cOCI8, "Server", &oci8_dont_free_handle_vtable);
+    cEnvironment = oci8_define_class_under(cOCI8, "Environment", &oci8_dont_free_handle_vtable);
+    cProcess = oci8_define_class_under(cOCI8, "Process", &oci8_dont_free_handle_vtable);
     id_at_session_handle = rb_intern("@session_handle");
     id_at_server_handle = rb_intern("@server_handle");
 
@@ -1135,7 +1134,7 @@
     rb_cv_set(cOCI8, "@@environment_handle", obj);
 
     /* setup the process handle */
-    obj = rb_obj_alloc(oci8_cOCIHandle);
+    obj = rb_obj_alloc(cProcess);
     base = DATA_PTR(obj);
     base->type = OCI_HTYPE_PROC;
     base->self = Qnil;



More information about the ruby-oci8-commit mailing list