# File lib/tramp/evented_mysql.rb, line 97
  def unbind
    log 'mysql disconnect', $!
    # cp = EventedMysql.instance_variable_get('@connection_pool') and cp.delete(self)
    @connected = false

    # XXX wait for the next tick until the current fd is removed completely from the reactor
    #
    # XXX in certain cases the new FD# (@mysql.socket) is the same as the old, since FDs are re-used
    # XXX without next_tick in these cases, unbind will get fired on the newly attached signature as well
    #
    # XXX do _NOT_ use EM.next_tick here. if a bunch of sockets disconnect at the same time, we want
    # XXX reconnects to happen after all the unbinds have been processed
    EM.add_timer(0) do
      log 'mysql reconnecting'
      @processing = false
      @mysql = EventedMysql._connect @opts
      @fd = @mysql.socket

      @signature = EM.attach_fd @mysql.socket, true
      EM.set_notify_readable @signature, true
      log 'mysql connected'
      EM.instance_variable_get('@conns')[@signature] = self
      @connected = true
      make_socket_blocking
      next_query
    end
  end