Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add backports for URI in ruby 1.8 Form decode & encode methods have been added in 1.9 and some tests use these methods. This is a monkeypatch, but it's used only in test environment for ruby 1.8. It should be fine. The code was for the most part copied from the internet with minor tweaks. Given it's pretty much completely isolated from anything (will be used ONLY in ruby 1.8) I'm ok to leave it as is, with little care of accuracy and style. * fix `perform': select(): Operation now in progress` in ruby 1.8.7 This appears to be a result of misplaced `#if` and `#endif` caused the default fallback to never be executed and `rc` would remain with initialized value (`-1`) and raise an exception: ``` switch(rc) { case -1: if(errno != EINTR) { rb_raise(rb_eRuntimeError, "select(): %s", strerror(errno)); break; } ``` This was the original flow with indentation: ``` #if defined(HAVE_RB_THREAD_BLOCKING_REGION) || defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) fdset_args.maxfd = maxfd+1; fdset_args.fdread = &fdread; fdset_args.fdwrite = &fdwrite; fdset_args.fdexcep = &fdexcep; fdset_args.tv = &tv; #ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL rc = (int)(VALUE) rb_thread_call_without_gvl((void *(*)(void *))curb_select, &fdset_args, RUBY_UBF_IO, 0); #elif HAVE_RB_THREAD_BLOCKING_REGION rc = rb_thread_blocking_region(curb_select, &fdset_args, RUBY_UBF_IO, 0); #elif HAVE_RB_THREAD_FD_SELECT rc = rb_thread_fd_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv); #else rc = rb_thread_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv); #endif #endif ``` Ruby 1.8 does not define `HAVE_RB_THREAD_BLOCKING_REGION` nor `HAVE_RB_THREAD_CALL_WITHOUT_GVL` and no code is executed because the `else` clausule applies to inner `ifdef`. New flow, after my changes with indentation: ``` #if defined(HAVE_RB_THREAD_BLOCKING_REGION) || defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) fdset_args.maxfd = maxfd+1; fdset_args.fdread = &fdread; fdset_args.fdwrite = &fdwrite; fdset_args.fdexcep = &fdexcep; fdset_args.tv = &tv; #endif #ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL rc = (int)(VALUE) rb_thread_call_without_gvl((void *(*)(void *))curb_select, &fdset_args, RUBY_UBF_IO, 0); #elif HAVE_RB_THREAD_BLOCKING_REGION rc = rb_thread_blocking_region(curb_select, &fdset_args, RUBY_UBF_IO, 0); #elif HAVE_RB_THREAD_FD_SELECT rc = rb_thread_fd_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv); #else rc = rb_thread_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv); #endif ``` Here even when all the features are unavailable we have a fallback to `rc = rb_thread_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv);`. This commit also changes `rb_thread_wait_for` to pass timeval explicityly rather than rely on `rb_time_timeval`. There must have been a change in ruby 1.9 because the `rb_time_timeval` does not work in 1.8.7. ``` - rb_thread_wait_for(rb_time_timeval(DBL2NUM(0.1))); + rb_thread_wait_for(tv_100ms); ``` * enable testing in ruby 1.8 This will allow us to continue support for 1.8 until we decide not to. There is no good reason for the code to not work in 1.8 and it will be good to know when we actually break compatibility.
- Loading branch information
Showing
7 changed files
with
125 additions
and
13 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source 'https://rubygems.org' | ||
|
||
gemspec | ||
|
||
gem 'rake', '< 12' # as of 12.0 rake requires ruby 1.9 | ||
gem 'test-unit', '< 3' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
curb (0.9.6) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
rake (10.5.0) | ||
test-unit (2.5.5) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
curb! | ||
rake (< 12) | ||
test-unit (< 3) | ||
|
||
BUNDLED WITH | ||
1.15.4 |
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
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
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
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