Skip to content

Instantly share code, notes, and snippets.

@matsumotory
Created February 15, 2018 02:49
Show Gist options
  • Save matsumotory/6d90cd3823edd2d62824a274965e446d to your computer and use it in GitHub Desktop.
Save matsumotory/6d90cd3823edd2d62824a274965e446d to your computer and use it in GitHub Desktop.
def _ngx_mruby_prepare_fiber(app_proc)
    p "call _ngx_mruby_prepare_fiber"
    fiber = Fiber.new do
      p "call fiber"
      app_proc.call
      p "done fiber"
    end

    Proc.new do
      p "call resume proc"
      rv = fiber.resume
      is_alive = fiber.alive?
      p [is_alive, rv]
    end
  end

これのapp_procにはmruby_rewrite_handler {code}のcodeのprocが入っているのだが、_ngx_mruby_prepare_fiberをC側からfuncallでprocを渡して、実行して帰ってきたprocをさらにfuncallで実行すると、なぜかapp_proc.callでC側にreturnされてしまう(fiber.resume以下のfiber.aliveなどが実行されない)けどこれは仕様か、というのを明日にでもMatzさんに聞く

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment