summaryrefslogtreecommitdiff
path: root/ext/dl/handle.c
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-24 21:56:50 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-24 21:56:50 +0000
commita631b5df366f0e7b1c6f16b53281df3822b9e833 (patch)
treecf9df8d4723c48093e139bc4f002b260ea358c8a /ext/dl/handle.c
parentc038e9003ce249d4f1346fef5b21883978a780ab (diff)
* ext/dl/handle.c (rb_dlhandle_close) check return value of dlclose()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/handle.c')
-rw-r--r--ext/dl/handle.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
index a9df5d61193..eee0cb26b0a 100644
--- a/ext/dl/handle.c
+++ b/ext/dl/handle.c
@@ -57,8 +57,21 @@ rb_dlhandle_close(VALUE self)
struct dl_handle *dlhandle;
TypedData_Get_Struct(self, struct dl_handle, &dlhandle_data_type, dlhandle);
- dlhandle->open = 0;
- return INT2NUM(dlclose(dlhandle->ptr));
+ if(dlhandle->open) {
+ dlhandle->open = 0;
+ int ret = dlclose(dlhandle->ptr);
+
+ /* Check dlclose for successful return value */
+ if(ret) {
+#if defined(HAVE_DLERROR)
+ rb_raise(rb_eDLError, dlerror());
+#else
+ rb_raise(rb_eDLError, "could not close handle");
+#endif
+ }
+ return INT2NUM(ret);
+ }
+ rb_raise(rb_eDLError, "dlclose() called too many times");
}
VALUE
@@ -301,3 +314,5 @@ Init_dlhandle(void)
rb_define_method(rb_cDLHandle, "disable_close", rb_dlhandle_disable_close, 0);
rb_define_method(rb_cDLHandle, "enable_close", rb_dlhandle_enable_close, 0);
}
+
+/* mode: c; tab-with=8; sw=8; ts=8; noexpandtab: */