Created
May 8, 2015 15:33
-
-
Save nagadomi/9a28d910651b547e1393 to your computer and use it in GitHub Desktop.
turbovisor segfault
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'open-uri' | |
| TARGET_URL = "http://localhost:8888/" | |
| TARGET_DIR = "./" | |
| CORE_FILE = "./core" | |
| def random_file_update | |
| rng = Random.new | |
| 10000.times do |i| | |
| filename = File.join(TARGET_DIR, sprintf("%d", i % 10)) | |
| File.open(filename, "wb") do |fp| | |
| fp.write rng.bytes(rng.rand(10 * 1024 * 1024) + 10 * 1024 * 1024) | |
| end | |
| sleep(rng.rand(0.0 .. 0.1)) | |
| #p "file" | |
| end | |
| end | |
| def random_http_access | |
| rng = Random.new | |
| 10000.times do |i| | |
| begin | |
| OpenURI.open_uri(TARGET_URL){|io| io.read } | |
| rescue => e | |
| # ignore error | |
| end | |
| sleep(rng.rand(0.0 .. 0.1)) | |
| #p "http" | |
| end | |
| end | |
| def find_core | |
| while true | |
| if File.exists?(CORE_FILE) | |
| puts "core dump!!" | |
| exit | |
| end | |
| sleep(1) | |
| end | |
| end | |
| threads = [] | |
| 2.times do | |
| # random file update thread | |
| threads << Thread.new do | |
| random_file_update() | |
| end | |
| # random http access thread | |
| threads << Thread.new do | |
| random_http_access() | |
| end | |
| end | |
| threads << Thread.new do | |
| find_core() | |
| end | |
| threads.each do |t| | |
| t.join | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local turbo = require("turbo") | |
| local TestHandler = class("TestHandler", turbo.web.RequestHandler) | |
| function TestHandler:get() | |
| self:write("test handler") | |
| end | |
| local app = turbo.web.Application:new({ | |
| {"/", TestHandler} | |
| }) | |
| app:listen(8888) | |
| turbo.ioloop.instance():start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment