<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -33,6 +33,12 @@
 #define RSTRING_LEN(x) RSTRING(x)-&gt;len 
 #endif
 
+#ifdef HAVE_RUBY19_HASH
+  #define RHASH_LEN(hash) RHASH(hash)-&gt;ntbl-&gt;num_entries
+#else
+  #define RHASH_LEN(hash) RHASH(hash)-&gt;tbl-&gt;num_entries
+#endif
+
 extern VALUE mCurl;
 
 extern void Init_curb_core();</diff>
      <filename>ext/curb.h</filename>
    </modified>
    <modified>
      <diff>@@ -41,9 +41,13 @@ static void curl_multi_flush_easy(VALUE key, VALUE easy, ruby_curl_multi *rbcm)
 
 static void curl_multi_free(ruby_curl_multi *rbcm) {
   //printf(&quot;hash entries: %d\n&quot;, RHASH(rbcm-&gt;requests)-&gt;tbl-&gt;num_entries );
-  rb_hash_foreach( rbcm-&gt;requests, (int (*)())curl_multi_flush_easy, (VALUE)rbcm );
+  if (RHASH_LEN(rbcm-&gt;requests) &gt; 0) {
+    rb_hash_foreach( rbcm-&gt;requests, (int (*)())curl_multi_flush_easy, (VALUE)rbcm );
 
-  curl_multi_cleanup(rbcm-&gt;handle);
+    curl_multi_cleanup(rbcm-&gt;handle);
+    //rb_hash_clear(rbcm-&gt;requests)
+    rbcm-&gt;requests = rb_hash_new();
+  }
 }
 
 /*</diff>
      <filename>ext/curb_multi.c</filename>
    </modified>
    <modified>
      <diff>@@ -35,7 +35,7 @@ def have_constant(name)
     end
   end
 end
-  
+
 have_constant &quot;curlinfo_redirect_time&quot;
 have_constant &quot;curlinfo_response_code&quot;
 have_constant &quot;curlinfo_filetime&quot;
@@ -75,5 +75,27 @@ if try_compile('int main() { return 0; }','-Wall')
   $CFLAGS &lt;&lt; ' -Wall'
 end
 
+# do some checking to detect ruby 1.8 hash.c vs ruby 1.9 hash.c
+def test_for(name, const, src)
+  checking_for &quot;Ruby 1.9&quot; do
+    if try_compile(src,&quot;#{$CFLAGS} #{$LIBS}&quot;)
+      define const
+      true
+    else
+      false
+    end
+  end
+end
+test_for(&quot;Ruby 1.9&quot;, &quot;RUBY19_HASH&quot;, %{
+  #include &lt;ruby.h&gt;
+  int main() {
+    VALUE hash = rb_hash_new();
+    if( RHASH(hash)-&gt;ntbl-&gt;num_entries ) {
+      return 0;
+    }
+    return 1;
+  }
+})
+
 create_header('curb_config.h')
 create_makefile('curb_core')</diff>
      <filename>ext/extconf.rb</filename>
    </modified>
    <modified>
      <diff>@@ -93,8 +93,16 @@ module TestServerMethods
       @server = WEBrick::HTTPServer.new :Port =&gt; port, :DocumentRoot =&gt; File.expand_path(File.dirname(__FILE__))
 
       @server.mount(servlet.path, servlet)
+      queue = Queue.new # synchronize the thread startup to the main thread
 
-      @test_thread = Thread.new { @server.start }
+      @test_thread = Thread.new { queue &lt;&lt; 1; @server.start }
+
+      # wait for the queue
+      value = queue.pop
+      if !value
+        STDERR.puts &quot;Failed to startup test server!&quot;
+        exit(1)
+      end
 
       exit_code = lambda do
         begin</diff>
      <filename>tests/helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>381ade3c7df2c1ca19787a4a5e08b0fe66ca2d96</id>
    </parent>
  </parents>
  <author>
    <name>Todd A. Fisher</name>
    <login></login>
    <email>taf2@web3.anerian.com</email>
  </author>
  <url>http://github.com/taf2/curb/commit/ab4137958f0a69776e3f107435c67ebc8c98051e</url>
  <id>ab4137958f0a69776e3f107435c67ebc8c98051e</id>
  <committed-date>2009-03-13T05:16:45-07:00</committed-date>
  <authored-date>2009-03-13T05:16:45-07:00</authored-date>
  <message>upgrade with support for ruby 1.9.1</message>
  <tree>aa36895a1da5de1d8d2a3c4972498f5a53228dca</tree>
  <committer>
    <name>Todd A. Fisher</name>
    <login></login>
    <email>taf2@web3.anerian.com</email>
  </committer>
</commit>
