<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -133,6 +133,7 @@ module Reactor
     # mode can be either :read or :write
     def detach(mode, io, force=false)
       selectables = @selectables[mode] || raise(&quot;mode is not :read or :write&quot;)
+      return unless selectables[:ios].include?(io.object_id)
       if !force &amp;&amp; selectables[:callbacks][io.object_id].length &gt; 1
         selectables[:callbacks][io.object_id].shift
       else
@@ -140,7 +141,7 @@ module Reactor
         selectables[:callbacks].delete(io.object_id)
         selectables[:dirty] = true
       end
-      @on_detach.call(mode, io) if @on_attach
+      @on_detach.call(mode, io) if @on_detach
     end
       
     # Supply a callback to on_detach that will be called
@@ -162,7 +163,7 @@ module Reactor
     #
     # mode can be either :read or :write
     def attached?(mode, io)
-      @selectables[mode][:ios].include? io
+      @selectables[mode][:ios].include? io.object_id
     end
 
     # Add a block of code that will fire after some time
@@ -215,7 +216,12 @@ module Reactor
     end
     
     def fire_ios(mode, ios)
-      ios.each {|io|@selectables[mode][:callbacks][io.object_id][0].call(io, self)}
+      ios.each do |io|  
+        # an io might get detached while we are in this loop
+        # so we just ignore it
+        callback = @selectables[mode][:callbacks][io.object_id]        
+        callback[0].call(io, self) if callback
+      end
     end
   end
 end </diff>
      <filename>lib/reactor.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 Gem::Specification.new do |s|
   s.name     = &quot;reactor&quot;
-  s.version  = &quot;0.2.2&quot;
-  s.date     = &quot;2009-07-09&quot;
+  s.version  = &quot;0.2.3&quot;
+  s.date     = &quot;2009-07-10&quot;
   s.summary  = &quot;A pure Ruby reactor library&quot;
   s.email    = &quot;oldmoe@gmail.com&quot;
   s.homepage = &quot;http://github.com/oldmoe/reactor&quot;</diff>
      <filename>reactor.gemspec</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>046215a2a089fb77c38fe4311c98250ef2c8ad2c</id>
    </parent>
  </parents>
  <author>
    <name>oldmoe</name>
    <email>oldmoe@gmail.com</email>
  </author>
  <url>http://github.com/oldmoe/reactor/commit/17b32708f5238df337b5f2b70a34a4f0454fee03</url>
  <id>17b32708f5238df337b5f2b70a34a4f0454fee03</id>
  <committed-date>2009-07-10T11:15:54-07:00</committed-date>
  <authored-date>2009-07-10T11:15:54-07:00</authored-date>
  <message>fixed a bug in attached? and added better io firing</message>
  <tree>5f03fab713c9d7960dd96c6278575b6e94904b6b</tree>
  <committer>
    <name>oldmoe</name>
    <email>oldmoe@gmail.com</email>
  </committer>
</commit>
