Created
June 24, 2009 15:11
-
-
Save taf2/135326 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git diff ext/curb.h | |
diff --git a/ext/curb.h b/ext/curb.h | |
index c40a5a0..0c04c63 100644 | |
--- a/ext/curb.h | |
+++ b/ext/curb.h | |
@@ -42,6 +42,18 @@ | |
#define RHASH_LEN(hash) RHASH(hash)->tbl->num_entries | |
#endif | |
+#ifdef HAVE_RUBY_THREAD_BLOCKING_REGION | |
+ struct rb_blocking_region_buffer *rb_thread_blocking_region_begin(void); | |
+ void rb_thread_blocking_region_end(struct rb_blocking_region_buffer *region); | |
+ #define RB_UNLOCK_BEGIN() do {struct rb_blocking_region_buffer *__curb__lock = rb_thread_blocking_region_begin(); | |
+ #define RB_UNLOCK_END() rb_thread_blocking_region_end(__curb__lock); } while(0) | |
+ #define RB_SELECT select | |
+#else | |
+ #define RB_UNLOCK_BEGIN() | |
+ #define RB_UNLOCK_END() | |
+ #define RB_SELECT rb_thread_select | |
+#endif | |
+ | |
extern VALUE mCurl; | |
extern void Init_curb_core(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git diff ext/curb_multi.c | |
diff --git a/ext/curb_multi.c b/ext/curb_multi.c | |
index 0306d30..cd9276a 100644 | |
--- a/ext/curb_multi.c | |
+++ b/ext/curb_multi.c | |
@@ -161,7 +161,9 @@ static VALUE ruby_curl_multi_add(VALUE self, VALUE easy) { | |
rbcm->active++; | |
if (mcode == CURLM_CALL_MULTI_PERFORM) { | |
- curl_multi_perform(rbcm->handle, &(rbcm->running)); | |
+// RB_UNLOCK_BEGIN(); | |
+ mcode = curl_multi_perform(rbcm->handle,&(rbcm->running)); | |
+// RB_UNLOCK_END(); | |
} | |
rb_hash_aset( rbcm->requests, easy, easy ); | |
@@ -281,9 +283,11 @@ static void rb_curl_multi_read_info(VALUE self, CURLM *multi_handle) { | |
static void rb_curl_multi_run(VALUE self, CURLM *multi_handle, int *still_running) { | |
CURLMcode mcode; | |
+// RB_UNLOCK_BEGIN(); | |
do { | |
mcode = curl_multi_perform(multi_handle, still_running); | |
} while (mcode == CURLM_CALL_MULTI_PERFORM); | |
+// RB_UNLOCK_END(); | |
if (mcode != CURLM_OK) { | |
raise_curl_multi_error_exception(mcode); | |
@@ -358,7 +362,10 @@ static VALUE ruby_curl_multi_perform(VALUE self) { | |
tv.tv_sec = timeout / 1000; | |
tv.tv_usec = (timeout * 1000) % 1000000; | |
- rc = rb_thread_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv); | |
+ RB_UNLOCK_BEGIN(); | |
+ rc = RB_SELECT(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv); | |
+ RB_UNLOCK_END(); | |
+ | |
if (rc < 0) { | |
rb_raise(rb_eRuntimeError, "select(): %s", strerror(errno)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment