about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-10-19 23:43:59 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-20 00:09:04 +0000
commitcd84e2ccbdf29b908c7d4711528d61bac05505bb (patch)
tree03e5cfd47e9a445094ccd559e2dd99095c0b422d /test
parentd4805769eb3174d25b429fa1faf5392b2669f354 (diff)
downloadyahns-cd84e2ccbdf29b908c7d4711528d61bac05505bb.tar.gz
Leaving running threads at exit seems to lead to occasional bugs at
finalization on Ruby 2.0.0.  This could be a bug with sleepy_penguin
or kgio, too, so I'll have to investigate further.  For now, we'll
just destroy the IOs associated with each queue and let the threads
die on their own.

This changes the QueueEgg internals a bit and I've removed the unit
test for QueueEgg now since the rest of the server already works
well (and QueueEgg internals may change even more).

Queues/worker threads no longer have their own logger, it seems like
excessive configurability/complexity since acceptors do not have
their own logger, either.  This logger only exists to log bugs in
yahns, not the application, so using the server logger is sufficient.
Diffstat (limited to 'test')
-rw-r--r--test/test_queue.rb62
1 files changed, 0 insertions, 62 deletions
diff --git a/test/test_queue.rb b/test/test_queue.rb
deleted file mode 100644
index cdb9ade..0000000
--- a/test/test_queue.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
-# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
-require_relative 'helper'
-require 'timeout'
-require 'stringio'
-
-class TestQueue < Testcase
-  parallelize_me!
-
-  def setup
-    @q = Yahns::Queue.new
-    @err = StringIO.new
-    @logger = Logger.new(@err)
-    @q.fdmap = @fdmap = Yahns::Fdmap.new(@logger, 0.5)
-    assert @q.close_on_exec?
-  end
-
-  def test_queue
-    r, w = IO.pipe
-    assert_equal 0, @fdmap.size
-    @q.queue_add(r, Yahns::Queue::QEV_RD)
-    assert_equal 1, @fdmap.size
-    def r.yahns_step
-      begin
-        case read_nonblock(11)
-        when "ignore"
-          return :ignore
-        end
-      rescue Errno::EAGAIN
-        return :wait_readable
-      rescue EOFError
-        return nil
-      end while true
-    end
-    w.write('.')
-    Timeout.timeout(10) do
-      Thread.pass until r.nread > 0
-      @q.spawn_worker_threads(@logger, 1, 1)
-      Thread.pass until r.nread == 0
-
-      assert_equal 1, @fdmap.size
-      w.write("ignore")
-      Thread.pass until r.nread == 0
-      Thread.pass until @fdmap.size == 0
-
-      assert_raises(Errno::EEXIST) {
-        @q.queue_add(r, Yahns::Queue::QEV_RD)
-      }
-      assert_equal 1, @fdmap.size
-      @q.epoll_ctl(SleepyPenguin::Epoll::CTL_MOD, r, Yahns::Queue::QEV_RD)
-      w.close
-      Thread.pass until @fdmap.size == 0
-    end
-    assert r.closed?
-  ensure
-    [ r, w ].each { |io| io.close unless io.closed? }
-  end
-
-  def teardown
-    @q.close
-  end
-end