diff --git a/README.rdoc b/README.rdoc index a8df4a5..c9f18d4 100644 --- a/README.rdoc +++ b/README.rdoc @@ -234,7 +234,7 @@ then iterating over every row using an #each like method yielding a block: == Special Thanks -* Eric Wong - for the contribution (and informative explanations of) of some thread-safety, non-blocking I/O and cleanup patches. You rock dude +* Eric Wong - for the contribution (and the informative explanations) of some thread-safety, non-blocking I/O and cleanup patches. You rock dude * Yury Korolev (http://github.com/yury) - for TONS of help testing the ActiveRecord adapter * Aaron Patterson (http://github.com/tenderlove) - tons of contributions, suggestions and general badassness * Mike Perham (http://github.com/mperham) - Async ActiveRecord adapter (uses Fibers and EventMachine) diff --git a/ext/mysql2/client.c b/ext/mysql2/client.c index 6079e81..b282864 100644 --- a/ext/mysql2/client.c +++ b/ext/mysql2/client.c @@ -113,26 +113,21 @@ static VALUE nogvl_close(void *ptr) { * we'll send a QUIT message to the server, but that message is more of a * formality than a hard requirement since the socket is getting shutdown * anyways, so ensure the socket write does not block our interpreter + * + * + * if the socket is dead we have no chance of blocking, + * so ignore any potential fcntl errors since they don't matter */ - int fd = wrapper->client->net.fd; - - if (fd >= 0) { - /* - * if the socket is dead we have no chance of blocking, - * so ignore any potential fcntl errors since they don't matter - */ - #ifndef _WIN32 - int flags = fcntl(fd, F_GETFL); - if (flags > 0 && !(flags & O_NONBLOCK)) - fcntl(fd, F_SETFL, flags | O_NONBLOCK); - #else - u_long iMode = 1; - ioctlsocket(fd, FIONBIO, &iMode); - #endif - } +#ifndef _WIN32 + int flags = fcntl(wrapper->client->net.fd, F_GETFL); + if (flags > 0 && !(flags & O_NONBLOCK)) + fcntl(wrapper->client->net.fd, F_SETFL, flags | O_NONBLOCK); +#else + u_long iMode = 1; + ioctlsocket(wrapper->client->net.fd, FIONBIO, &iMode); +#endif mysql_close(wrapper->client); - wrapper->client->net.fd = -1; free(wrapper->client); } diff --git a/lib/active_record/connection_adapters/mysql2_adapter.rb b/lib/active_record/connection_adapters/mysql2_adapter.rb index a442fa8..c72c3c4 100644 --- a/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -622,7 +622,8 @@ module ActiveRecord variable_assignments << "NAMES '#{encoding}'" if encoding # increase timeout so mysql server doesn't disconnect us - variable_assignments << "@@wait_timeout = #{@config[:wait_timeout] || 2592000}" + wait_timeout = @config[:wait_timeout] || 2592000 + variable_assignments << "@@wait_timeout = #{wait_timeout}" if wait_timeout.is_a?(Fixnum) execute("SET #{variable_assignments.join(', ')}", :skip_logging) end diff --git a/mysql2.gemspec b/mysql2.gemspec index 75a9b8a..4dedcec 100644 --- a/mysql2.gemspec +++ b/mysql2.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Brian Lopez"] - s.date = %q{2010-09-17} + s.date = %q{2010-10-18} s.email = %q{seniorlopez@gmail.com} s.extensions = ["ext/mysql2/extconf.rb"] s.extra_rdoc_files = [ @@ -17,6 +17,7 @@ Gem::Specification.new do |s| ] s.files = [ ".gitignore", + ".rspec", "CHANGELOG.md", "MIT-LICENSE", "README.rdoc", @@ -29,7 +30,6 @@ Gem::Specification.new do |s| "benchmark/query_without_mysql_casting.rb", "benchmark/sequel.rb", "benchmark/setup_db.rb", - "benchmark/thread_alone.rb", "examples/eventmachine.rb", "examples/threaded.rb", "ext/mysql2/client.c", @@ -54,10 +54,11 @@ Gem::Specification.new do |s| "spec/mysql2/error_spec.rb", "spec/mysql2/result_spec.rb", "spec/rcov.opts", - "spec/spec.opts", "spec/spec_helper.rb", "tasks/benchmarks.rake", "tasks/compile.rake", + "tasks/jeweler.rake", + "tasks/rspec.rake", "tasks/vendor_mysql.rake" ] s.homepage = %q{http://github.com/brianmario/mysql2}