VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/lib/gems/2.5.0/gems/eventmachine-1.2.7/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/lib/gems/2.5.0/gems/eventmachine-1.2.7/tests/test_connection_write.rb
require 'em_test_helper'

class TestConnectionWrite < Test::Unit::TestCase

  # This test takes advantage of the fact that EM::_RunSelectOnce iterates over the connections twice:
  #   - once to determine which ones to call Write() on
  #   - and once to call Write() on each of them.
  #
  # But state may change in the meantime before Write() is finally called.
  # And that is what we try to exploit to get Write() to be called when bWatchOnly is true, and bNotifyWritable is false,
  # to cause an assertion failure.

  module SimpleClient
    def notify_writable
      $conn2.notify_writable = false  # Being naughty in callback
      # If this doesn't crash anything, the test passed!
    end
  end

  def test_with_naughty_callback
    EM.run do
      r1, _ = IO.pipe
      r2, _ = IO.pipe

      # Adding EM.watches
      $conn1 = EM.watch(r1, SimpleClient)
      $conn2 = EM.watch(r2, SimpleClient)

      $conn1.notify_writable = true
      $conn2.notify_writable = true

      EM.stop
    end
  end
end

VaKeR 2022