<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/c_threaded_test.rb</filename>
    </added>
    <added>
      <filename>test/native_threaded_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -269,11 +269,14 @@ static VALUE real_connect(int argc, VALUE* argv, VALUE klass)
 
     myp-&gt;handler.reconnect = 0;
     myp-&gt;connection = Qtrue;
-    
+
     my_bool was_blocking;
+
     vio_blocking(myp-&gt;handler.net.vio, 0, &amp;was_blocking);    
     myp-&gt;blocking = vio_is_blocking( myp-&gt;handler.net.vio );
 
+    vio_fastsend( myp-&gt;handler.net.vio );
+
     myp-&gt;query_with_result = Qtrue;
     rb_obj_call_init(obj, argc, argv);
 
@@ -762,6 +765,14 @@ static VALUE socket(VALUE obj)
     return INT2NUM(m-&gt;net.fd);
 }
 
+/* socket_type */
+static VALUE socket_type(VALUE obj)
+{
+    MYSQL* m = GetHandler(obj);
+    VALUE description = vio_description( m-&gt;net.vio );
+    return NILorSTRING( description );
+}
+
 /* blocking */
 static VALUE blocking(VALUE obj){
   return ( GetMysqlStruct(obj)-&gt;blocking ? Qtrue : Qfalse );
@@ -825,28 +836,27 @@ static VALUE async_query(int argc, VALUE* argv, VALUE obj)
 
   send_query(obj,sql);
 
-  if (NIL_P(timeout)) {
-    timeout = m-&gt;net.read_timeout;
-  }
+  timeout = ( NIL_P(timeout) ? m-&gt;net.read_timeout : INT2NUM(timeout) );
 
   VALUE args[1];
   args[0] = timeout;
 
   struct timeval tv = { tv_sec: timeout, tv_usec: 0 };
 
+  FD_ZERO(&amp;read);
+  FD_SET(m-&gt;net.fd, &amp;read);
+
   for(;;) {
-    FD_ZERO(&amp;read);
-    FD_SET(m-&gt;net.fd, &amp;read);
       ret = rb_thread_select(m-&gt;net.fd + 1, &amp;read, NULL, NULL, &amp;tv);
       if (ret &lt; 0) {
-        rb_sys_fail(0);
+        rb_raise(eMysql, &quot;query: timeout&quot;);
       }
               
       if (ret == 0) {
         continue;
       }
 
-      if (readable(1, (VALUE *)args, obj) == Qtrue) {
+      if ( vio_poll_read( m-&gt;net.vio, INT2NUM(timeout) ) == 0 ) {
         break;
       }
   }
@@ -2147,6 +2157,7 @@ void Init_mysql(void)
     rb_define_method(cMysql, &quot;readable?&quot;, readable, -1);
     rb_define_method(cMysql, &quot;blocking?&quot;, blocking, 0);
     rb_define_method(cMysql, &quot;socket&quot;, socket, 0);
+    rb_define_method(cMysql, &quot;socket_type&quot;, socket_type, 0);
     rb_define_method(cMysql, &quot;refresh&quot;, refresh, 1);
     rb_define_method(cMysql, &quot;reload&quot;, reload, 0);
     rb_define_method(cMysql, &quot;select_db&quot;, select_db, 1);</diff>
      <filename>ext/mysql.c</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,8 @@ Gem::Specification.new do |s|
 		&quot;Rakefile&quot;,
 		&quot;lib/mysqlplus.rb&quot;,
 		&quot;test/test_helper.rb&quot;,
-		&quot;test/threaded_test.rb&quot;,
+		&quot;test/native_threaded_test.rb&quot;,
+		&quot;test/c_threaded_test.rb&quot;,
 		&quot;test/evented_test.rb&quot;,
 		&quot;ext/error_const.h&quot;,
 		&quot;ext/extconf.rb&quot;,</diff>
      <filename>mysqlplus.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,11 @@
 require File.dirname(__FILE__) + '/test_helper'
 
+EventedMysqlTest.new( 10, &quot;Evented, very small overhead&quot; ) do |test|
+  test.setup{ Mysql.real_connect('localhost','root') }
+  test.per_query_overhead = 0.005
+  test.run!
+end
+
 EventedMysqlTest.new( 10, &quot;Evented, small overhead&quot; ) do |test|
   test.setup{ Mysql.real_connect('localhost','root') }
   test.per_query_overhead = 0.1</diff>
      <filename>test/evented_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,7 +13,8 @@ class MysqlTest
                 :start,
                 :done,
                 :c_async_query,
-                :per_query_overhead
+                :per_query_overhead,
+                :timeout
   
   def initialize( queries, context = '' )
     @queries = queries
@@ -21,6 +22,7 @@ class MysqlTest
     @done = []
     @c_async_query = false
     @per_query_overhead = 3
+    @timeout = 20
     yield self if block_given?
   end
   
@@ -186,7 +188,7 @@ class ThreadedMysqlTest &lt; MysqlTest
 
           log &quot;sending query on connection #{conn}&quot;
 
-          c_or_native_async_query( @connections[conn], &quot;select sleep(#{@per_query_overhead})&quot; ).each do |result|
+          c_or_native_async_query( @connections[conn], &quot;select sleep(#{@per_query_overhead})&quot;, @timeout ).each do |result|
             log &quot;connection #{conn} done&quot;
           end 
         </diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/threaded_test.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>6c2b9ecb84e9b36289800187960bbfe0661f0712</id>
    </parent>
  </parents>
  <author>
    <name>Lourens Naude</name>
    <email>lourens@methodmissing.com</email>
  </author>
  <url>http://github.com/oldmoe/mysqlplus/commit/6884d454bcb5377ffee61110ccd1e6e75abce096</url>
  <id>6884d454bcb5377ffee61110ccd1e6e75abce096</id>
  <committed-date>2008-09-09T16:33:18-07:00</committed-date>
  <authored-date>2008-09-09T16:33:18-07:00</authored-date>
  <message>Use TCP_NODELAY if supported; Remove file descriptor ops from the tight loop; Cleanup timeout assignment; Split the threaded test suite in native and c to avoid a large number of active Threads affecting results.Add experimental Mysql#socket_type which typically returns 'socket (x)', but may be helpful for debugging purposes.</message>
  <tree>ecb6b5c1101048cd54516a798dfe0f3309a18151</tree>
  <committer>
    <name>Lourens Naude</name>
    <email>lourens@methodmissing.com</email>
  </committer>
</commit>
